5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MATH_FLOAT_PROPERTIES_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MATH_FLOAT_PROPERTIES_HPP_
14#include "arene/base/stdlib_choice/enable_if.hpp"
15#include "arene/base/stdlib_choice/forward.hpp"
16#include "arene/base/stdlib_choice/is_floating_point.hpp"
17#include "arene/base/stdlib_choice/is_same.hpp"
18#include "arene/base/stdlib_choice/numeric_limits.hpp"
30ARENE_IGNORE_ALL(
"-Wfloat-equal",
"Equality is used to check the properties of a single value, not compare two values");
32namespace float_properties_detail {
38template <typename T, constraints<std::enable_if_t<std::is_floating_point<T>::value>> =
nullptr>
39constexpr auto isnan(T
const num)
noexcept ->
bool {
48template <typename T, constraints<std::enable_if_t<std::is_floating_point<T>::value>> =
nullptr>
49constexpr auto isinf(T
const num)
noexcept ->
bool {
57template <typename T, constraints<std::enable_if_t<std::is_floating_point<T>::value>> =
nullptr>
58constexpr auto isfinite(T
const num)
noexcept ->
bool {
59 return (!::arene::base::float_properties_detail::isnan(num)) && (!::arene::base::float_properties_detail::isinf(num));
66template <typename T, constraints<std::enable_if_t<std::is_floating_point<T>::value>> =
nullptr>
67constexpr auto isnormal(T num)
noexcept ->
bool {
70 if (::arene::base::float_properties_detail::isnan(num)) {
74 if (num <
static_cast<T
>(0.0)) {
94 constexpr auto operator()(T&& value)
const noexcept(
noexcept(isnan(
std::forward<T>(value))))
99 std::is_same<decltype(isnan(std::forward<T>(value))),
bool>::value,
100 "ADL overload of isnan must return bool"
114 template <
typename T>
115 constexpr auto operator()(T&& value)
const noexcept(
noexcept(isinf(
std::forward<T>(value))))
116 ->
decltype(
static_cast<void>(isinf(
std::forward<T>(value))),
bool{}) {
120 std::is_same<decltype(isinf(std::forward<T>(value))),
bool>::value,
121 "ADL overload of isinf must return bool"
135 template <
typename T>
136 constexpr auto operator()(T&& value)
const noexcept(
noexcept(isfinite(
std::forward<T>(value))))
137 ->
decltype(
static_cast<void>(isfinite(
std::forward<T>(value))),
bool{}) {
141 std::is_same<decltype(isfinite(std::forward<T>(value))),
bool>::value,
142 "ADL overload of isfinite must return bool"
156 template <
typename T>
157 constexpr auto operator()(T&& value)
const noexcept(
noexcept(isnormal(
std::forward<T>(value))))
158 ->
decltype(
static_cast<void>(isnormal(
std::forward<T>(value))),
bool{}) {
162 std::is_same<decltype(isnormal(std::forward<T>(value))),
bool>::value,
163 "ADL overload of isnormal must return bool"
#define ARENE_CPP14_INLINE_VARIABLE(type, name)
Emulates C++17's inline variable declarations for function objects.
Definition cpp14_inline.hpp:69
static constexpr auto min() noexcept -> T
The minimum finite value; the minimum positive normalized value for floating point types.
Definition numeric_limits.hpp:235
static constexpr auto infinity() noexcept -> T
For floating point types where has_infinity is true, a representation of positive infinity.
Definition numeric_limits.hpp:249
Provides macros used to disable and enable compiler specific diagnostics using the _Pragma operator.
#define ARENE_IGNORE_END()
Ends a region of a suppressed diagnostic.
Definition diagnostics.hpp:136
#define ARENE_IGNORE_START()
Begins a region of a suppressed diagnostic.
Definition diagnostics.hpp:131
#define ARENE_IGNORE_ALL(s, comment)
Pushes an ignore for a diagnostic into the compiler for any compiler.
Definition diagnostics.hpp:122
Definition accumulate.hpp:37
Definition accumulate.hpp:36
constexpr auto forward(remove_reference_t< T > &value) noexcept -> T &&
Cast a value to an rvalue if T is an rvalue or rvalue reference, otherwise forward an lvalue referenc...
Definition forward.hpp:24