]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Copyright 2015 John Maddock. Distributed under the Boost | |
3 | // Software License, Version 1.0. (See accompanying file | |
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | #include <boost/multiprecision/cpp_int.hpp> | |
1e59de90 | 7 | #include <type_traits> |
7c673cae | 8 | |
92f5a8d4 | 9 | typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::int128_t::backend_type> > rat128_t; |
7c673cae | 10 | typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::uint128_t::backend_type> > urat128_t; |
92f5a8d4 | 11 | typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::int512_t::backend_type> > rat512_t; |
7c673cae FG |
12 | typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::uint512_t::backend_type> > urat512_t; |
13 | ||
92f5a8d4 | 14 | typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::checked_int128_t::backend_type> > checked_rat128_t; |
7c673cae | 15 | typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::checked_uint128_t::backend_type> > checked_urat128_t; |
92f5a8d4 | 16 | typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::checked_int512_t::backend_type> > checked_rat512_t; |
7c673cae FG |
17 | typedef boost::multiprecision::number<boost::multiprecision::rational_adaptor<boost::multiprecision::checked_uint512_t::backend_type> > checked_urat512_t; |
18 | ||
7c673cae FG |
19 | // |
20 | // Move construct: | |
21 | // | |
1e59de90 TL |
22 | static_assert(std::is_nothrow_move_constructible<boost::multiprecision::cpp_rational>::value, "is_nothrow_move_constructible test"); |
23 | static_assert(std::is_nothrow_move_constructible<rat128_t>::value, "is_nothrow_move_constructible test"); | |
24 | static_assert(std::is_nothrow_move_constructible<checked_rat128_t>::value, "is_nothrow_move_constructible test"); | |
25 | static_assert(std::is_nothrow_move_constructible<urat128_t>::value, "is_nothrow_move_constructible test"); | |
26 | static_assert(std::is_nothrow_move_constructible<checked_urat128_t>::value, "is_nothrow_move_constructible test"); | |
27 | static_assert(std::is_nothrow_move_constructible<rat512_t>::value, "is_nothrow_move_constructible test"); | |
28 | static_assert(std::is_nothrow_move_constructible<checked_rat512_t>::value, "is_nothrow_move_constructible test"); | |
29 | static_assert(std::is_nothrow_move_constructible<urat512_t>::value, "is_nothrow_move_constructible test"); | |
30 | static_assert(std::is_nothrow_move_constructible<checked_urat512_t>::value, "is_nothrow_move_constructible test"); | |
7c673cae FG |
31 | // |
32 | // Move assign: | |
33 | // | |
1e59de90 TL |
34 | static_assert(std::is_nothrow_move_assignable<boost::multiprecision::cpp_rational>::value, "is_nothrow_move_assignable test"); |
35 | static_assert(std::is_nothrow_move_assignable<rat128_t>::value, "is_nothrow_move_assignable test"); | |
36 | static_assert(std::is_nothrow_move_assignable<checked_rat128_t>::value, "is_nothrow_move_assignable test"); | |
37 | static_assert(std::is_nothrow_move_assignable<urat128_t>::value, "is_nothrow_move_assignable test"); | |
38 | static_assert(std::is_nothrow_move_assignable<checked_urat128_t>::value, "is_nothrow_move_assignable test"); | |
39 | static_assert(std::is_nothrow_move_assignable<rat512_t>::value, "is_nothrow_move_assignable test"); | |
40 | static_assert(std::is_nothrow_move_assignable<checked_rat512_t>::value, "is_nothrow_move_assignable test"); | |
41 | static_assert(std::is_nothrow_move_assignable<urat512_t>::value, "is_nothrow_move_assignable test"); | |
42 | static_assert(std::is_nothrow_move_assignable<checked_urat512_t>::value, "is_nothrow_move_assignable test"); | |
7c673cae FG |
43 | |
44 | #if 0 | |
45 | // | |
46 | // Everything below could/should be made to work, given modifications to Boost.Rational | |
47 | // | |
48 | ||
49 | ||
50 | // | |
51 | // Construct: | |
52 | // | |
53 | #ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR | |
1e59de90 TL |
54 | static_assert(boost::has_nothrow_constructor<boost::multiprecision::cpp_rational>::value); |
55 | static_assert(boost::has_nothrow_constructor<rat128_t>::value); | |
56 | static_assert(boost::has_nothrow_constructor<checked_rat128_t>::value); | |
57 | static_assert(boost::has_nothrow_constructor<urat128_t>::value); | |
58 | static_assert(boost::has_nothrow_constructor<checked_urat128_t>::value); | |
59 | static_assert(boost::has_nothrow_constructor<rat512_t>::value); | |
60 | static_assert(boost::has_nothrow_constructor<checked_rat512_t>::value); | |
61 | static_assert(boost::has_nothrow_constructor<urat512_t>::value); | |
62 | static_assert(boost::has_nothrow_constructor<checked_urat512_t>::value); | |
7c673cae FG |
63 | #endif |
64 | // | |
65 | // Copy construct: | |
66 | // | |
67 | #ifdef BOOST_HAS_NOTHROW_COPY | |
1e59de90 TL |
68 | static_assert(!boost::has_nothrow_copy<boost::multiprecision::cpp_rational>::value); |
69 | static_assert(boost::has_nothrow_copy<rat128_t>::value); | |
70 | static_assert(boost::has_nothrow_copy<checked_rat128_t>::value); | |
71 | static_assert(boost::has_nothrow_copy<urat128_t>::value); | |
72 | static_assert(boost::has_nothrow_copy<checked_urat128_t>::value); | |
73 | static_assert(boost::has_nothrow_copy<rat512_t>::value); | |
74 | static_assert(boost::has_nothrow_copy<checked_rat512_t>::value); | |
75 | static_assert(boost::has_nothrow_copy<urat512_t>::value); | |
76 | static_assert(boost::has_nothrow_copy<checked_urat512_t>::value); | |
7c673cae FG |
77 | #endif |
78 | // | |
79 | // Assign: | |
80 | // | |
81 | #ifdef BOOST_HAS_NOTHROW_ASSIGN | |
1e59de90 TL |
82 | static_assert(!boost::has_nothrow_assign<boost::multiprecision::cpp_rational>::value); |
83 | static_assert(boost::has_nothrow_assign<rat128_t>::value); | |
84 | static_assert(boost::has_nothrow_assign<checked_rat128_t>::value); | |
85 | static_assert(boost::has_nothrow_assign<urat128_t>::value); | |
86 | static_assert(boost::has_nothrow_assign<checked_urat128_t>::value); | |
87 | static_assert(boost::has_nothrow_assign<rat512_t>::value); | |
88 | static_assert(boost::has_nothrow_assign<checked_rat512_t>::value); | |
89 | static_assert(boost::has_nothrow_assign<urat512_t>::value); | |
90 | static_assert(boost::has_nothrow_assign<checked_urat512_t>::value); | |
7c673cae FG |
91 | #endif |
92 | // | |
93 | // Construct from int: | |
94 | // | |
1e59de90 TL |
95 | static_assert(noexcept(boost::multiprecision::cpp_rational(std::declval<boost::multiprecision::signed_limb_type>()))); |
96 | static_assert(noexcept(rat128_t(std::declval<boost::multiprecision::signed_limb_type>()))); | |
97 | static_assert(noexcept(checked_rat128_t(std::declval<boost::multiprecision::signed_limb_type>()))); | |
98 | static_assert(noexcept(urat128_t(std::declval<boost::multiprecision::signed_limb_type>()))); | |
99 | static_assert(!noexcept(checked_urat128_t(std::declval<boost::multiprecision::signed_limb_type>()))); | |
100 | static_assert(noexcept(rat512_t(std::declval<boost::multiprecision::signed_limb_type>()))); | |
101 | static_assert(noexcept(checked_rat512_t(std::declval<boost::multiprecision::signed_limb_type>()))); | |
102 | static_assert(noexcept(urat512_t(std::declval<boost::multiprecision::signed_limb_type>()))); | |
103 | static_assert(!noexcept(checked_urat512_t(std::declval<boost::multiprecision::signed_limb_type>()))); | |
7c673cae FG |
104 | // |
105 | // Construct from unsigned int: | |
106 | // | |
1e59de90 TL |
107 | static_assert(noexcept(boost::multiprecision::cpp_rational(std::declval<boost::multiprecision::limb_type>()))); |
108 | static_assert(noexcept(rat128_t(std::declval<boost::multiprecision::limb_type>()))); | |
109 | static_assert(noexcept(checked_rat128_t(std::declval<boost::multiprecision::limb_type>()))); | |
110 | static_assert(noexcept(urat128_t(std::declval<boost::multiprecision::limb_type>()))); | |
111 | static_assert(noexcept(checked_urat128_t(std::declval<boost::multiprecision::limb_type>()))); | |
112 | static_assert(noexcept(rat512_t(std::declval<boost::multiprecision::limb_type>()))); | |
113 | static_assert(noexcept(checked_rat512_t(std::declval<boost::multiprecision::limb_type>()))); | |
114 | static_assert(noexcept(urat512_t(std::declval<boost::multiprecision::limb_type>()))); | |
115 | static_assert(noexcept(checked_urat512_t(std::declval<boost::multiprecision::limb_type>()))); | |
7c673cae FG |
116 | // |
117 | // Assign from int: | |
118 | // | |
1e59de90 TL |
119 | static_assert(noexcept(std::declval<boost::multiprecision::cpp_rational>() = std::declval<boost::multiprecision::signed_limb_type>())); |
120 | static_assert(noexcept(std::declval<rat128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); | |
121 | static_assert(noexcept(std::declval<checked_rat128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); | |
122 | static_assert(noexcept(std::declval<urat128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); | |
123 | static_assert(!noexcept(std::declval<checked_urat128_t>() = std::declval<boost::multiprecision::signed_limb_type>())); | |
124 | static_assert(noexcept(std::declval<rat512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); | |
125 | static_assert(noexcept(std::declval<checked_rat512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); | |
126 | static_assert(noexcept(std::declval<urat512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); | |
127 | static_assert(!noexcept(std::declval<checked_urat512_t>() = std::declval<boost::multiprecision::signed_limb_type>())); | |
7c673cae FG |
128 | // |
129 | // Assign from unsigned int: | |
130 | // | |
1e59de90 TL |
131 | static_assert(noexcept(std::declval<boost::multiprecision::cpp_rational>() = std::declval<boost::multiprecision::limb_type>())); |
132 | static_assert(noexcept(std::declval<rat128_t>() = std::declval<boost::multiprecision::limb_type>())); | |
133 | static_assert(noexcept(std::declval<checked_rat128_t>() = std::declval<boost::multiprecision::limb_type>())); | |
134 | static_assert(noexcept(std::declval<urat128_t>() = std::declval<boost::multiprecision::limb_type>())); | |
135 | static_assert(noexcept(std::declval<checked_urat128_t>() = std::declval<boost::multiprecision::limb_type>())); | |
136 | static_assert(noexcept(std::declval<rat512_t>() = std::declval<boost::multiprecision::limb_type>())); | |
137 | static_assert(noexcept(std::declval<checked_rat512_t>() = std::declval<boost::multiprecision::limb_type>())); | |
138 | static_assert(noexcept(std::declval<urat512_t>() = std::declval<boost::multiprecision::limb_type>())); | |
139 | static_assert(noexcept(std::declval<checked_urat512_t>() = std::declval<boost::multiprecision::limb_type>())); | |
7c673cae FG |
140 | |
141 | #if defined(BOOST_LITTLE_ENDIAN) | |
142 | // | |
143 | // Construct from int: | |
144 | // | |
1e59de90 TL |
145 | static_assert(noexcept(boost::multiprecision::cpp_rational(std::declval<boost::multiprecision::signed_double_limb_type>()))); |
146 | static_assert(noexcept(rat128_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); | |
147 | static_assert(noexcept(checked_rat128_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); | |
148 | static_assert(noexcept(urat128_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); | |
149 | static_assert(!noexcept(checked_urat128_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); | |
150 | static_assert(noexcept(rat512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); | |
151 | static_assert(noexcept(checked_rat512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); | |
152 | static_assert(noexcept(urat512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); | |
153 | static_assert(!noexcept(checked_urat512_t(std::declval<boost::multiprecision::signed_double_limb_type>()))); | |
7c673cae FG |
154 | // |
155 | // Construct from unsigned int: | |
156 | // | |
1e59de90 TL |
157 | static_assert(noexcept(boost::multiprecision::cpp_rational(std::declval<boost::multiprecision::double_limb_type>()))); |
158 | static_assert(noexcept(rat128_t(std::declval<boost::multiprecision::double_limb_type>()))); | |
159 | static_assert(noexcept(checked_rat128_t(std::declval<boost::multiprecision::double_limb_type>()))); | |
160 | static_assert(noexcept(urat128_t(std::declval<boost::multiprecision::double_limb_type>()))); | |
161 | static_assert(noexcept(checked_urat128_t(std::declval<boost::multiprecision::double_limb_type>()))); | |
162 | static_assert(noexcept(rat512_t(std::declval<boost::multiprecision::double_limb_type>()))); | |
163 | static_assert(noexcept(checked_rat512_t(std::declval<boost::multiprecision::double_limb_type>()))); | |
164 | static_assert(noexcept(urat512_t(std::declval<boost::multiprecision::double_limb_type>()))); | |
165 | static_assert(noexcept(checked_urat512_t(std::declval<boost::multiprecision::double_limb_type>()))); | |
7c673cae FG |
166 | // |
167 | // Assign from int: | |
168 | // | |
1e59de90 TL |
169 | static_assert(noexcept(std::declval<boost::multiprecision::cpp_rational>() = std::declval<boost::multiprecision::signed_double_limb_type>())); |
170 | static_assert(noexcept(std::declval<rat128_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); | |
171 | static_assert(noexcept(std::declval<checked_rat128_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); | |
172 | static_assert(noexcept(std::declval<urat128_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); | |
173 | static_assert(!noexcept(std::declval<checked_urat128_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); | |
174 | static_assert(noexcept(std::declval<rat512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); | |
175 | static_assert(noexcept(std::declval<checked_rat512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); | |
176 | static_assert(noexcept(std::declval<urat512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); | |
177 | static_assert(!noexcept(std::declval<checked_urat512_t>() = std::declval<boost::multiprecision::signed_double_limb_type>())); | |
7c673cae FG |
178 | // |
179 | // Assign from unsigned int: | |
180 | // | |
1e59de90 TL |
181 | static_assert(noexcept(std::declval<boost::multiprecision::cpp_rational>() = std::declval<boost::multiprecision::double_limb_type>())); |
182 | static_assert(noexcept(std::declval<rat128_t>() = std::declval<boost::multiprecision::double_limb_type>())); | |
183 | static_assert(noexcept(std::declval<checked_rat128_t>() = std::declval<boost::multiprecision::double_limb_type>())); | |
184 | static_assert(noexcept(std::declval<urat128_t>() = std::declval<boost::multiprecision::double_limb_type>())); | |
185 | static_assert(noexcept(std::declval<checked_urat128_t>() = std::declval<boost::multiprecision::double_limb_type>())); | |
186 | static_assert(noexcept(std::declval<rat512_t>() = std::declval<boost::multiprecision::double_limb_type>())); | |
187 | static_assert(noexcept(std::declval<checked_rat512_t>() = std::declval<boost::multiprecision::double_limb_type>())); | |
188 | static_assert(noexcept(std::declval<urat512_t>() = std::declval<boost::multiprecision::double_limb_type>())); | |
189 | static_assert(noexcept(std::declval<checked_urat512_t>() = std::declval<boost::multiprecision::double_limb_type>())); | |
7c673cae FG |
190 | |
191 | #endif | |
192 | #endif // little endian |