Program Listing for File number.hpp¶
↰ Return to documentation for file (include/ripple/utility/number.hpp
)
#ifndef RIPPLE_UTILITY_NUMBER_HPP
#define RIPPLE_UTILITY_NUMBER_HPP
#include "portability.hpp"
namespace ripple {
template <size_t Value>
struct Num {
static constexpr auto value = size_t{Value};
ripple_all constexpr operator size_t() const noexcept {
return Value;
}
};
template <int64_t Value>
struct Int64 {
static constexpr auto value = int64_t{Value};
ripple_all constexpr operator int64_t() const noexcept {
return Value;
}
};
namespace detail {
template <typename T>
struct IsNumber {
static constexpr bool value = false;
};
template <size_t Value>
struct IsNumber<Num<Value>> {
static constexpr bool value = true;
};
template <int64_t Value>
struct IsNumber<Int64<Value>> {
static constexpr bool value = true;
};
} // namespace detail
template <typename T>
static constexpr bool is_number_v = detail::IsNumber<std::decay_t<T>>::value;
} // namespace ripple
#endif // RIPPLE_UTILITY_NUMBER_HPP