0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd::fpe: Add classification reflector; additional noexcept linkages.

This commit is contained in:
Jason Volk 2021-03-07 01:34:12 -08:00
parent 4abf868b39
commit 925eee5209
2 changed files with 27 additions and 2 deletions

View file

@ -16,8 +16,11 @@ namespace ircd::fpe
struct errors_handle;
struct scope_round;
string_view reflect_sicode(const int &);
string_view reflect(const ushort &flag);
template<class T>
string_view classify(const T &) noexcept;
string_view reflect_sicode(const int &) noexcept;
string_view reflect(const ushort &flag) noexcept;
string_view reflect(const mutable_buffer &, const ushort &flags);
[[noreturn]] void _throw_errors(const ushort &flags);

View file

@ -46,6 +46,7 @@ ircd::fpe::reflect(const mutable_buffer &buf,
ircd::string_view
ircd::fpe::reflect(const ushort &flag)
noexcept
{
switch(flag)
{
@ -62,6 +63,7 @@ ircd::fpe::reflect(const ushort &flag)
ircd::string_view
ircd::fpe::reflect_sicode(const int &code)
noexcept
{
switch(code)
{
@ -79,3 +81,23 @@ ircd::fpe::reflect_sicode(const int &code)
return "?????";
}
template<class T>
ircd::string_view
ircd::fpe::classify(const T &a)
noexcept
{
switch(std::fpclassify(a))
{
case FP_NAN: return "NAN";
case FP_ZERO: return "ZERO";
case FP_NORMAL: return "NORMAL";
case FP_SUBNORMAL: return "SUBNORMAL";
case FP_INFINITE: return "INFINITE";
}
return "????";
}
template ircd::string_view ircd::fpe::classify(const long double &a) noexcept;
template ircd::string_view ircd::fpe::classify(const double &a) noexcept;
template ircd::string_view ircd::fpe::classify(const float &a) noexcept;