7 #if !defined(CNL_IMPL_ELASTIC_TAG_OVERLOADS_H)
8 #define CNL_IMPL_ELASTIC_TAG_OVERLOADS_H
10 #include "../num_traits/set_width.h"
11 #include "../num_traits/width.h"
12 #include "../numbers/set_signedness.h"
13 #include "../numbers/signedness.h"
14 #include "definition.h"
23 binary_arithmetic_op Operator,
int LhsDigits,
typename LhsNarrowest,
int RhsDigits,
24 typename RhsNarrowest>
25 struct elastic_tag_overload_params {
26 using policy =
typename _impl::policy<
27 Operator, LhsDigits, numbers::signedness_v<LhsNarrowest>, RhsDigits,
28 numbers::signedness_v<RhsNarrowest>>;
29 using narrowest = _impl::set_width_t<
30 numbers::set_signedness_t<
31 _impl::op_result<Operator, LhsNarrowest, RhsNarrowest>,
34 _impl::width<LhsNarrowest>, _impl::width<RhsNarrowest>)>;
36 using type = elastic_tag<policy::digits, narrowest>;
40 template<
int LhsDigits,
typename LhsNarrowest,
int RhsDigits,
typename RhsNarrowest>
41 [[nodiscard]] constexpr
auto operator+(
42 elastic_tag<LhsDigits, LhsNarrowest>, elastic_tag<RhsDigits, RhsNarrowest>) ->
43 typename _impl::elastic_tag_overload_params<
44 _impl::add_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type
46 return typename _impl::elastic_tag_overload_params<
47 _impl::add_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type{};
50 template<
int LhsDigits,
typename LhsNarrowest,
int RhsDigits,
typename RhsNarrowest>
51 [[nodiscard]] constexpr
auto operator-(
52 elastic_tag<LhsDigits, LhsNarrowest>, elastic_tag<RhsDigits, RhsNarrowest>) ->
53 typename _impl::elastic_tag_overload_params<
54 _impl::subtract_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type
56 return typename _impl::elastic_tag_overload_params<
57 _impl::subtract_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type{};
60 template<
int LhsDigits,
typename LhsNarrowest,
int RhsDigits,
typename RhsNarrowest>
61 [[nodiscard]] constexpr
auto operator*(
62 elastic_tag<LhsDigits, LhsNarrowest>, elastic_tag<RhsDigits, RhsNarrowest>) ->
63 typename _impl::elastic_tag_overload_params<
64 _impl::multiply_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type
66 return typename _impl::elastic_tag_overload_params<
67 _impl::multiply_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type{};
70 template<
int LhsDigits,
typename LhsNarrowest,
int RhsDigits,
typename RhsNarrowest>
71 [[nodiscard]] constexpr
auto operator/(
72 elastic_tag<LhsDigits, LhsNarrowest>, elastic_tag<RhsDigits, RhsNarrowest>) ->
73 typename _impl::elastic_tag_overload_params<
74 _impl::divide_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type
76 return typename _impl::elastic_tag_overload_params<
77 _impl::divide_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type{};
80 template<
int LhsDigits,
typename LhsNarrowest,
int RhsDigits,
typename RhsNarrowest>
81 [[nodiscard]] constexpr
auto operator%(
82 elastic_tag<LhsDigits, LhsNarrowest>, elastic_tag<RhsDigits, RhsNarrowest>) ->
83 typename _impl::elastic_tag_overload_params<
84 _impl::modulo_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type
86 return typename _impl::elastic_tag_overload_params<
87 _impl::modulo_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type{};
90 template<
int LhsDigits,
typename LhsNarrowest,
int RhsDigits,
typename RhsNarrowest>
91 [[nodiscard]] constexpr
auto operator&(
92 elastic_tag<LhsDigits, LhsNarrowest>, elastic_tag<RhsDigits, RhsNarrowest>) ->
93 typename _impl::elastic_tag_overload_params<
94 _impl::bitwise_and_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type
96 return typename _impl::elastic_tag_overload_params<
97 _impl::bitwise_and_op, LhsDigits, LhsNarrowest, RhsDigits, RhsNarrowest>::type{};
101 #endif // CNL_IMPL_ELASTIC_TAG_OVERLOADS_H