7 #if !defined(CNL_ROUNDING_INTEGER_H)
8 #define CNL_ROUNDING_INTEGER_H
10 #include "_impl/custom_operator/tagged.h"
11 #include "_impl/num_traits/is_composite.h"
12 #include "_impl/num_traits/rep_of.h"
13 #include "_impl/num_traits/rounding.h"
14 #include "_impl/num_traits/set_rounding.h"
15 #include "_impl/num_traits/to_rep.h"
17 #include "_impl/rounding/convert_operator.h"
18 #include "_impl/rounding/is_rounding_tag.h"
19 #include "_impl/rounding/nearest_rounding_tag.h"
20 #include "_impl/wrapper.h"
22 #include <type_traits>
34 template<
typename Rep =
int, rounding_tag Tag = nearest_rounding_tag>
41 template<_impl::any_wrapper Number>
42 requires(!_impl::is_rounding_tag<typename Number::tag>::value)
struct rounding<Number>
47 template<
typename Rep, rounding_tag Tag>
48 struct rounding<_impl::wrapper<Rep, Tag>>
49 : std::type_identity<Tag> {
55 template<
typename Number, rounding_tag Tag>
56 requires(is_composite<Number>::value && !_impl::is_wrapper<Number>)
struct set_rounding<Number, Tag>
58 _impl::set_rep_t<Number, set_rounding_t<_impl::rep_of_t<Number>, Tag>>> {
62 template<
int Digits,
class Rep, rounding_tag Tag>
63 requires(Digits < 0) struct scale<Digits, 2, _impl::wrapper<Rep, Tag>>
64 : _impl::default_scale<Digits, 2, _impl::wrapper<Rep, Tag>> {
68 template<
int Digits,
int Radix,
class Rep, rounding_tag Tag>
69 requires(0 <= Digits)
struct scale<
70 Digits, Radix, _impl::wrapper<Rep, Tag>> {
71 [[nodiscard]] constexpr
auto operator()(_impl::wrapper<Rep, Tag>
const& s)
const
73 return _impl::from_rep<_impl::wrapper<Rep, Tag>>(
74 scale<Digits, Radix, Rep>{}(_impl::to_rep(s)));
82 template<
typename NumberRep, rounding_tag NumberTag,
typename Rep>
83 requires(!_impl::is_wrapper<Rep>)
struct set_rep<
84 _impl::wrapper<NumberRep, NumberTag>, Rep>
85 : std::type_identity<_impl::wrapper<Rep, NumberTag>> {
92 template<
typename NumberRep, rounding_tag NumberTag, tag Tag>
93 struct set_tag<_impl::wrapper<NumberRep, NumberTag>, Tag>
94 : std::type_identity<_impl::wrapper<NumberRep, Tag>> {
98 #endif // CNL_ROUNDING_INTEGER_H