mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 08:42:34 +01:00
ircd::util: Consolidate a few typographical constexprs here.
This commit is contained in:
parent
81c3a87ee5
commit
1b8e93d487
1 changed files with 68 additions and 1 deletions
|
@ -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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue