7 #if !defined(CNL_IMPL_NUM_TRAITS_FROM_VALUE_H)
8 #define CNL_IMPL_NUM_TRAITS_FROM_VALUE_H
10 #include "../../constant.h"
11 #include "../numbers/set_signedness.h"
12 #include "../type_traits/remove_cvref.h"
13 #include "../used_digits.h"
15 #include "set_digits.h"
22 template<
typename Result,
typename Value>
23 struct from_value_simple {
24 [[nodiscard]] constexpr
auto operator()(Value
const& value)
const
31 template<
typename Number,
typename Value>
33 void operator()(Value
const&)
const;
36 template<std::
integral Number,
class Value>
37 struct from_value<Number, Value>
38 : _impl::from_value_simple<Value, Value> {
41 template<std::
integral Number, CNL_IMPL_CONSTANT_VALUE_TYPE Value>
42 struct from_value<Number, constant<Value>> {
45 numbers::set_signedness_t<Number, true>,
46 std::max(digits_v<int>, _impl::used_digits(Value))>;
49 [[nodiscard]] constexpr
auto operator()(constant<Value>
const& value)
const
51 return result_type(value);
56 template<
typename Number,
typename Value>
57 [[nodiscard]] constexpr
auto from_value(Value
const& value)
58 -> decltype(cnl::from_value<Number, remove_cvref_t<Value>>{}(value))
60 return cnl::from_value<Number, remove_cvref_t<Value>>{}(value);
64 template<
typename Number,
typename Value>
65 using from_value_t = decltype(_impl::from_value<Number>(std::declval<Value>()));
68 #endif // CNL_IMPL_NUM_TRAITS_FROM_VALUE_H