12 #ifndef BOOST_MPL11_RATIONAL_HPP
13 #define BOOST_MPL11_RATIONAL_HPP
28 namespace boost {
namespace mpl11 {
29 template <
typename T, T numerator, T denominator>
31 using type = rational_c;
32 using mpl_datatype = Rational;
34 static constexpr T num = numerator;
35 static constexpr T den = denominator;
39 struct cast<Integer, Rational> {
42 using apply = rational_c<
43 typename i::value_type, i::value
48 struct Monoid<Rational> : instantiate<Monoid>::with<Rational> {
49 template <
typename x,
typename y>
50 using plus_impl = rational_c<
51 decltype(
true ? x::num : y::num),
52 (x::num * y::den) + (x::den * y::num),
56 template <
typename ...>
57 using zero_impl = rational_c<long long, 0>;
61 struct Group<Rational> : instantiate<Group>::with<Rational> {
62 template <
typename x,
typename y>
63 using minus_impl = rational_c<
64 decltype(
true ? x::num : y::num),
65 (x::num * y::den) - (x::den * y::num),
70 using negate_impl = rational_c<
71 decltype(-x::num), -x::num, x::den
76 struct Ring<Rational> : instantiate<Ring>::with<Rational> {
77 template <
typename x,
typename y>
78 using mult_impl = rational_c<
79 decltype(
true ? x::num : y::num),
84 template <
typename ...>
85 using one_impl = rational_c<long long, 1>;
89 struct Field<Rational> : instantiate<Field>::with<Rational> {
90 template <
typename x,
typename y>
91 using quot_impl = rational_c<
92 decltype(
true ? x::num : y::num),
98 using recip_impl = rational_c<
99 decltype(x::num), x::den, x::num
104 struct Comparable<Rational> : instantiate<Comparable>::with<Rational> {
105 template <
typename x,
typename y>
106 using equal_impl = bool_<
107 x::num * y::den == x::den * y::num
110 template <
typename x,
typename y>
111 using not_equal_impl = bool_<
112 x::num * y::den != x::den * y::num
117 struct Orderable<Rational> : instantiate<Orderable>::with<Rational> {
118 template <
typename x,
typename y>
119 using less_impl = bool_<(
120 x::num * y::den < x::den * y::num
123 template <
typename x,
typename y>
124 using less_equal_impl = bool_<(
125 x::num * y::den <= x::den * y::num
128 template <
typename x,
typename y>
129 using greater_impl = bool_<(
130 x::num * y::den > x::den * y::num
133 template <
typename x,
typename y>
134 using greater_equal_impl = bool_<(
135 x::num * y::den >= x::den * y::num
140 #endif // !BOOST_MPL11_RATIONAL_HPP
Forward declares the Rational datatype.
Defines the Ring typeclass.
Defines the Comparable typeclass.
Defines the Field typeclass.
Defines the methods of the Enumerable typeclass.
Invokes a metafunction class with the given arguments.
Definition: functional.hpp:39
Defines the Group typeclass.
Defines the Orderable typeclass.
Forwards to boost/mpl11/integer.hpp.
Defines the Monoid typeclass.