0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-19 08:21:09 +01:00

ircd::util: Consolidate a few typographical constexprs here.

This commit is contained in:
Jason Volk 2017-11-25 12:30:33 -07:00
parent 81c3a87ee5
commit 1b8e93d487

View file

@ -1260,12 +1260,79 @@ struct unlock_guard
}; };
template<class T>
constexpr bool
is_bool()
{
using type = typename std::remove_reference<T>::type;
return std::is_same<type, bool>::value;
}
template<class T>
constexpr bool
is_number()
{
using type = typename std::remove_reference<T>::type;
return std::is_arithmetic<type>::value;
}
template<class T>
constexpr bool
is_floating()
{
using type = typename std::remove_reference<T>::type;
return is_number<T>() && std::is_floating_point<type>();
}
template<class T>
constexpr bool
is_integer()
{
return is_number<T>() && !is_floating<T>();
}
struct is_zero struct is_zero
{ {
bool operator()(const size_t &value) const template<class T>
typename std::enable_if
<
is_bool<T>(),
bool>::type
test(const bool &value)
const
{
return !value;
}
template<class T>
typename std::enable_if
<
is_integer<T>() &&
!is_bool<T>(),
bool>::type
test(const size_t &value)
const
{ {
return value == 0; return value == 0;
} }
template<class T>
typename std::enable_if
<
is_floating<T>(),
bool>::type
test(const double &value)
const
{
return !(value > 0.0 || value < 0.0);
}
template<class T>
bool operator()(T&& t)
const
{
return test<T>(std::forward<T>(t));
}
}; };