no_et_ops.hpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright 2012 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. #ifndef BOOST_MP_NO_ET_OPS_HPP
  6. #define BOOST_MP_NO_ET_OPS_HPP
  7. #ifdef BOOST_MSVC
  8. #pragma warning(push)
  9. #pragma warning(disable: 4714)
  10. #endif
  11. namespace boost{
  12. namespace multiprecision{
  13. //
  14. // Operators for non-expression template enabled number.
  15. // NOTE: this is not a complete header - really just a suffix to default_ops.hpp.
  16. // NOTE: these operators have to be defined after the methods in default_ops.hpp.
  17. //
  18. template <class B>
  19. BOOST_MP_FORCEINLINE number<B, et_off> operator - (const number<B, et_off>& v)
  20. {
  21. BOOST_STATIC_ASSERT_MSG(is_signed_number<B>::value, "Negating an unsigned type results in ill-defined behavior.");
  22. number<B, et_off> result(v);
  23. result.backend().negate();
  24. return BOOST_MP_MOVE(result);
  25. }
  26. template <class B>
  27. BOOST_MP_FORCEINLINE number<B, et_off> operator ~ (const number<B, et_off>& v)
  28. {
  29. number<B, et_off> result;
  30. eval_complement(result.backend(), v.backend());
  31. return BOOST_MP_MOVE(result);
  32. }
  33. //
  34. // Addition:
  35. //
  36. template <class B>
  37. BOOST_MP_FORCEINLINE number<B, et_off> operator + (const number<B, et_off>& a, const number<B, et_off>& b)
  38. {
  39. number<B, et_off> result;
  40. using default_ops::eval_add;
  41. eval_add(result.backend(), a.backend(), b.backend());
  42. return BOOST_MP_MOVE(result);
  43. }
  44. template <class B, class V>
  45. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  46. operator + (const number<B, et_off>& a, const V& b)
  47. {
  48. number<B, et_off> result;
  49. using default_ops::eval_add;
  50. eval_add(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
  51. return BOOST_MP_MOVE(result);
  52. }
  53. template <class V, class B>
  54. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  55. operator + (const V& a, const number<B, et_off>& b)
  56. {
  57. number<B, et_off> result;
  58. using default_ops::eval_add;
  59. eval_add(result.backend(), b.backend(), number<B, et_off>::canonical_value(a));
  60. return BOOST_MP_MOVE(result);
  61. }
  62. //
  63. // Subtraction:
  64. //
  65. template <class B>
  66. BOOST_MP_FORCEINLINE number<B, et_off> operator - (const number<B, et_off>& a, const number<B, et_off>& b)
  67. {
  68. number<B, et_off> result;
  69. using default_ops::eval_subtract;
  70. eval_subtract(result.backend(), a.backend(), b.backend());
  71. return BOOST_MP_MOVE(result);
  72. }
  73. template <class B, class V>
  74. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  75. operator - (const number<B, et_off>& a, const V& b)
  76. {
  77. number<B, et_off> result;
  78. using default_ops::eval_subtract;
  79. eval_subtract(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
  80. return BOOST_MP_MOVE(result);
  81. }
  82. template <class V, class B>
  83. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  84. operator - (const V& a, const number<B, et_off>& b)
  85. {
  86. number<B, et_off> result;
  87. using default_ops::eval_subtract;
  88. eval_subtract(result.backend(), number<B, et_off>::canonical_value(a), b.backend());
  89. return BOOST_MP_MOVE(result);
  90. }
  91. //
  92. // Multiply:
  93. //
  94. template <class B>
  95. BOOST_MP_FORCEINLINE number<B, et_off> operator * (const number<B, et_off>& a, const number<B, et_off>& b)
  96. {
  97. number<B, et_off> result;
  98. using default_ops::eval_multiply;
  99. eval_multiply(result.backend(), a.backend(), b.backend());
  100. return BOOST_MP_MOVE(result);
  101. }
  102. template <class B, class V>
  103. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  104. operator * (const number<B, et_off>& a, const V& b)
  105. {
  106. number<B, et_off> result;
  107. using default_ops::eval_multiply;
  108. eval_multiply(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
  109. return BOOST_MP_MOVE(result);
  110. }
  111. template <class V, class B>
  112. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  113. operator * (const V& a, const number<B, et_off>& b)
  114. {
  115. number<B, et_off> result;
  116. using default_ops::eval_multiply;
  117. eval_multiply(result.backend(), b.backend(), number<B, et_off>::canonical_value(a));
  118. return BOOST_MP_MOVE(result);
  119. }
  120. //
  121. // divide:
  122. //
  123. template <class B>
  124. BOOST_MP_FORCEINLINE number<B, et_off> operator / (const number<B, et_off>& a, const number<B, et_off>& b)
  125. {
  126. number<B, et_off> result;
  127. using default_ops::eval_divide;
  128. eval_divide(result.backend(), a.backend(), b.backend());
  129. return BOOST_MP_MOVE(result);
  130. }
  131. template <class B, class V>
  132. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  133. operator / (const number<B, et_off>& a, const V& b)
  134. {
  135. number<B, et_off> result;
  136. using default_ops::eval_divide;
  137. eval_divide(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
  138. return BOOST_MP_MOVE(result);
  139. }
  140. template <class V, class B>
  141. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  142. operator / (const V& a, const number<B, et_off>& b)
  143. {
  144. number<B, et_off> result;
  145. using default_ops::eval_divide;
  146. eval_divide(result.backend(), number<B, et_off>::canonical_value(a), b.backend());
  147. return BOOST_MP_MOVE(result);
  148. }
  149. //
  150. // modulus:
  151. //
  152. template <class B>
  153. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator % (const number<B, et_off>& a, const number<B, et_off>& b)
  154. {
  155. number<B, et_off> result;
  156. using default_ops::eval_modulus;
  157. eval_modulus(result.backend(), a.backend(), b.backend());
  158. return BOOST_MP_MOVE(result);
  159. }
  160. template <class B, class V>
  161. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  162. operator % (const number<B, et_off>& a, const V& b)
  163. {
  164. number<B, et_off> result;
  165. using default_ops::eval_modulus;
  166. eval_modulus(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
  167. return BOOST_MP_MOVE(result);
  168. }
  169. template <class V, class B>
  170. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  171. operator % (const V& a, const number<B, et_off>& b)
  172. {
  173. number<B, et_off> result;
  174. using default_ops::eval_modulus;
  175. eval_modulus(result.backend(), number<B, et_off>::canonical_value(a), b.backend());
  176. return BOOST_MP_MOVE(result);
  177. }
  178. //
  179. // Bitwise or:
  180. //
  181. template <class B>
  182. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator | (const number<B, et_off>& a, const number<B, et_off>& b)
  183. {
  184. number<B, et_off> result;
  185. using default_ops::eval_bitwise_or;
  186. eval_bitwise_or(result.backend(), a.backend(), b.backend());
  187. return BOOST_MP_MOVE(result);
  188. }
  189. template <class B, class V>
  190. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  191. operator | (const number<B, et_off>& a, const V& b)
  192. {
  193. number<B, et_off> result;
  194. using default_ops::eval_bitwise_or;
  195. eval_bitwise_or(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
  196. return BOOST_MP_MOVE(result);
  197. }
  198. template <class V, class B>
  199. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  200. operator | (const V& a, const number<B, et_off>& b)
  201. {
  202. number<B, et_off> result;
  203. using default_ops::eval_bitwise_or;
  204. eval_bitwise_or(result.backend(), b.backend(), number<B, et_off>::canonical_value(a));
  205. return BOOST_MP_MOVE(result);
  206. }
  207. //
  208. // Bitwise xor:
  209. //
  210. template <class B>
  211. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator ^ (const number<B, et_off>& a, const number<B, et_off>& b)
  212. {
  213. number<B, et_off> result;
  214. using default_ops::eval_bitwise_xor;
  215. eval_bitwise_xor(result.backend(), a.backend(), b.backend());
  216. return BOOST_MP_MOVE(result);
  217. }
  218. template <class B, class V>
  219. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  220. operator ^ (const number<B, et_off>& a, const V& b)
  221. {
  222. number<B, et_off> result;
  223. using default_ops::eval_bitwise_xor;
  224. eval_bitwise_xor(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
  225. return BOOST_MP_MOVE(result);
  226. }
  227. template <class V, class B>
  228. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  229. operator ^ (const V& a, const number<B, et_off>& b)
  230. {
  231. number<B, et_off> result;
  232. using default_ops::eval_bitwise_xor;
  233. eval_bitwise_xor(result.backend(), b.backend(), number<B, et_off>::canonical_value(a));
  234. return BOOST_MP_MOVE(result);
  235. }
  236. //
  237. // Bitwise and:
  238. //
  239. template <class B>
  240. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator & (const number<B, et_off>& a, const number<B, et_off>& b)
  241. {
  242. number<B, et_off> result;
  243. using default_ops::eval_bitwise_and;
  244. eval_bitwise_and(result.backend(), a.backend(), b.backend());
  245. return BOOST_MP_MOVE(result);
  246. }
  247. template <class B, class V>
  248. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  249. operator & (const number<B, et_off>& a, const V& b)
  250. {
  251. number<B, et_off> result;
  252. using default_ops::eval_bitwise_and;
  253. eval_bitwise_and(result.backend(), a.backend(), number<B, et_off>::canonical_value(b));
  254. return BOOST_MP_MOVE(result);
  255. }
  256. template <class V, class B>
  257. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  258. operator & (const V& a, const number<B, et_off>& b)
  259. {
  260. number<B, et_off> result;
  261. using default_ops::eval_bitwise_and;
  262. eval_bitwise_and(result.backend(), b.backend(), number<B, et_off>::canonical_value(a));
  263. return BOOST_MP_MOVE(result);
  264. }
  265. //
  266. // shifts:
  267. //
  268. template <class B, class I>
  269. BOOST_MP_FORCEINLINE typename enable_if_c<is_integral<I>::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  270. operator << (const number<B, et_off>& a, const I& b)
  271. {
  272. number<B, et_off> result(a);
  273. using default_ops::eval_left_shift;
  274. detail::check_shift_range(b, mpl::bool_<(sizeof(I) > sizeof(std::size_t))>(), is_signed<I>());
  275. eval_left_shift(result.backend(), b);
  276. return BOOST_MP_MOVE(result);
  277. }
  278. template <class B, class I>
  279. BOOST_MP_FORCEINLINE typename enable_if_c<is_integral<I>::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  280. operator >> (const number<B, et_off>& a, const I& b)
  281. {
  282. number<B, et_off> result(a);
  283. using default_ops::eval_right_shift;
  284. detail::check_shift_range(b, mpl::bool_<(sizeof(I) > sizeof(std::size_t))>(), is_signed<I>());
  285. eval_right_shift(result.backend(), b);
  286. return BOOST_MP_MOVE(result);
  287. }
  288. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !(defined(__GNUC__) && ((__GNUC__ == 4) && (__GNUC_MINOR__ < 5)))
  289. //
  290. // If we have rvalue references go all over again with rvalue ref overloads and move semantics.
  291. // Note that while it would be tempting to implement these so they return an rvalue reference
  292. // (and indeed this would be optimally efficient), this is unsafe due to users propensity to
  293. // write:
  294. //
  295. // const T& t = a * b;
  296. //
  297. // which would lead to a dangling reference if we didn't return by value. Of course move
  298. // semantics help a great deal in return by value, so performance is still pretty good...
  299. //
  300. template <class B>
  301. BOOST_MP_FORCEINLINE number<B, et_off> operator - (number<B, et_off>&& v)
  302. {
  303. BOOST_STATIC_ASSERT_MSG(is_signed_number<B>::value, "Negating an unsigned type results in ill-defined behavior.");
  304. v.backend().negate();
  305. return static_cast<number<B, et_off>&&>(v);
  306. }
  307. template <class B>
  308. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator ~ (number<B, et_off>&& v)
  309. {
  310. eval_complement(v.backend(), v.backend());
  311. return static_cast<number<B, et_off>&&>(v);
  312. }
  313. //
  314. // Addition:
  315. //
  316. template <class B>
  317. BOOST_MP_FORCEINLINE number<B, et_off> operator + (number<B, et_off>&& a, const number<B, et_off>& b)
  318. {
  319. using default_ops::eval_add;
  320. eval_add(a.backend(), b.backend());
  321. return static_cast<number<B, et_off>&&>(a);
  322. }
  323. template <class B>
  324. BOOST_MP_FORCEINLINE number<B, et_off> operator + (const number<B, et_off>& a, number<B, et_off>&& b)
  325. {
  326. using default_ops::eval_add;
  327. eval_add(b.backend(), a.backend());
  328. return static_cast<number<B, et_off>&&>(b);
  329. }
  330. template <class B>
  331. BOOST_MP_FORCEINLINE number<B, et_off> operator + (number<B, et_off>&& a, number<B, et_off>&& b)
  332. {
  333. using default_ops::eval_add;
  334. eval_add(a.backend(), b.backend());
  335. return static_cast<number<B, et_off>&&>(a);
  336. }
  337. template <class B, class V>
  338. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  339. operator + (number<B, et_off>&& a, const V& b)
  340. {
  341. using default_ops::eval_add;
  342. eval_add(a.backend(), number<B, et_off>::canonical_value(b));
  343. return static_cast<number<B, et_off>&&>(a);
  344. }
  345. template <class V, class B>
  346. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  347. operator + (const V& a, number<B, et_off>&& b)
  348. {
  349. using default_ops::eval_add;
  350. eval_add(b.backend(), number<B, et_off>::canonical_value(a));
  351. return static_cast<number<B, et_off>&&>(b);
  352. }
  353. //
  354. // Subtraction:
  355. //
  356. template <class B>
  357. BOOST_MP_FORCEINLINE number<B, et_off> operator - (number<B, et_off>&& a, const number<B, et_off>& b)
  358. {
  359. using default_ops::eval_subtract;
  360. eval_subtract(a.backend(), b.backend());
  361. return static_cast<number<B, et_off>&&>(a);
  362. }
  363. template <class B>
  364. BOOST_MP_FORCEINLINE typename enable_if<is_signed_number<B>, number<B, et_off> >::type operator - (const number<B, et_off>& a, number<B, et_off>&& b)
  365. {
  366. using default_ops::eval_subtract;
  367. eval_subtract(b.backend(), a.backend());
  368. b.backend().negate();
  369. return static_cast<number<B, et_off>&&>(b);
  370. }
  371. template <class B>
  372. BOOST_MP_FORCEINLINE number<B, et_off> operator - (number<B, et_off>&& a, number<B, et_off>&& b)
  373. {
  374. using default_ops::eval_subtract;
  375. eval_subtract(a.backend(), b.backend());
  376. return static_cast<number<B, et_off>&&>(a);
  377. }
  378. template <class B, class V>
  379. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  380. operator - (number<B, et_off>&& a, const V& b)
  381. {
  382. using default_ops::eval_subtract;
  383. eval_subtract(a.backend(), number<B, et_off>::canonical_value(b));
  384. return static_cast<number<B, et_off>&&>(a);
  385. }
  386. template <class V, class B>
  387. BOOST_MP_FORCEINLINE typename enable_if_c<(is_compatible_arithmetic_type<V, number<B, et_off> >::value && is_signed_number<B>::value), number<B, et_off> >::type
  388. operator - (const V& a, number<B, et_off>&& b)
  389. {
  390. using default_ops::eval_subtract;
  391. eval_subtract(b.backend(), number<B, et_off>::canonical_value(a));
  392. b.backend().negate();
  393. return static_cast<number<B, et_off>&&>(b);
  394. }
  395. //
  396. // Multiply:
  397. //
  398. template <class B>
  399. BOOST_MP_FORCEINLINE number<B, et_off> operator * (number<B, et_off>&& a, const number<B, et_off>& b)
  400. {
  401. using default_ops::eval_multiply;
  402. eval_multiply(a.backend(), b.backend());
  403. return static_cast<number<B, et_off>&&>(a);
  404. }
  405. template <class B>
  406. BOOST_MP_FORCEINLINE number<B, et_off> operator * (const number<B, et_off>& a, number<B, et_off>&& b)
  407. {
  408. using default_ops::eval_multiply;
  409. eval_multiply(b.backend(), a.backend());
  410. return static_cast<number<B, et_off>&&>(b);
  411. }
  412. template <class B>
  413. BOOST_MP_FORCEINLINE number<B, et_off> operator * (number<B, et_off>&& a, number<B, et_off>&& b)
  414. {
  415. using default_ops::eval_multiply;
  416. eval_multiply(a.backend(), b.backend());
  417. return static_cast<number<B, et_off>&&>(a);
  418. }
  419. template <class B, class V>
  420. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  421. operator * (number<B, et_off>&& a, const V& b)
  422. {
  423. using default_ops::eval_multiply;
  424. eval_multiply(a.backend(), number<B, et_off>::canonical_value(b));
  425. return static_cast<number<B, et_off>&&>(a);
  426. }
  427. template <class V, class B>
  428. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  429. operator * (const V& a, number<B, et_off>&& b)
  430. {
  431. using default_ops::eval_multiply;
  432. eval_multiply(b.backend(), number<B, et_off>::canonical_value(a));
  433. return static_cast<number<B, et_off>&&>(b);
  434. }
  435. //
  436. // divide:
  437. //
  438. template <class B>
  439. BOOST_MP_FORCEINLINE number<B, et_off> operator / (number<B, et_off>&& a, const number<B, et_off>& b)
  440. {
  441. using default_ops::eval_divide;
  442. eval_divide(a.backend(), b.backend());
  443. return static_cast<number<B, et_off>&&>(a);
  444. }
  445. template <class B, class V>
  446. BOOST_MP_FORCEINLINE typename enable_if<is_compatible_arithmetic_type<V, number<B, et_off> >, number<B, et_off> >::type
  447. operator / (number<B, et_off>&& a, const V& b)
  448. {
  449. using default_ops::eval_divide;
  450. eval_divide(a.backend(), number<B, et_off>::canonical_value(b));
  451. return static_cast<number<B, et_off>&&>(a);
  452. }
  453. //
  454. // modulus:
  455. //
  456. template <class B>
  457. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator % (number<B, et_off>&& a, const number<B, et_off>& b)
  458. {
  459. using default_ops::eval_modulus;
  460. eval_modulus(a.backend(), b.backend());
  461. return static_cast<number<B, et_off>&&>(a);
  462. }
  463. template <class B, class V>
  464. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  465. operator % (number<B, et_off>&& a, const V& b)
  466. {
  467. using default_ops::eval_modulus;
  468. eval_modulus(a.backend(), number<B, et_off>::canonical_value(b));
  469. return static_cast<number<B, et_off>&&>(a);
  470. }
  471. //
  472. // Bitwise or:
  473. //
  474. template <class B>
  475. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator | (number<B, et_off>&& a, const number<B, et_off>& b)
  476. {
  477. using default_ops::eval_bitwise_or;
  478. eval_bitwise_or(a.backend(), b.backend());
  479. return static_cast<number<B, et_off>&&>(a);
  480. }
  481. template <class B>
  482. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator | (const number<B, et_off>& a, number<B, et_off>&& b)
  483. {
  484. using default_ops::eval_bitwise_or;
  485. eval_bitwise_or(b.backend(), a.backend());
  486. return static_cast<number<B, et_off>&&>(b);
  487. }
  488. template <class B>
  489. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator | (number<B, et_off>&& a, number<B, et_off>&& b)
  490. {
  491. using default_ops::eval_bitwise_or;
  492. eval_bitwise_or(a.backend(), b.backend());
  493. return static_cast<number<B, et_off>&&>(a);
  494. }
  495. template <class B, class V>
  496. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  497. operator | (number<B, et_off>&& a, const V& b)
  498. {
  499. using default_ops::eval_bitwise_or;
  500. eval_bitwise_or(a.backend(), number<B, et_off>::canonical_value(b));
  501. return static_cast<number<B, et_off>&&>(a);
  502. }
  503. template <class V, class B>
  504. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  505. operator | (const V& a, number<B, et_off>&& b)
  506. {
  507. using default_ops::eval_bitwise_or;
  508. eval_bitwise_or(b.backend(), number<B, et_off>::canonical_value(a));
  509. return static_cast<number<B, et_off>&&>(b);
  510. }
  511. //
  512. // Bitwise xor:
  513. //
  514. template <class B>
  515. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator ^ (number<B, et_off>&& a, const number<B, et_off>& b)
  516. {
  517. using default_ops::eval_bitwise_xor;
  518. eval_bitwise_xor(a.backend(), b.backend());
  519. return static_cast<number<B, et_off>&&>(a);
  520. }
  521. template <class B>
  522. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator ^ (const number<B, et_off>& a, number<B, et_off>&& b)
  523. {
  524. using default_ops::eval_bitwise_xor;
  525. eval_bitwise_xor(b.backend(), a.backend());
  526. return static_cast<number<B, et_off>&&>(b);
  527. }
  528. template <class B>
  529. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator ^ (number<B, et_off>&& a, number<B, et_off>&& b)
  530. {
  531. using default_ops::eval_bitwise_xor;
  532. eval_bitwise_xor(a.backend(), b.backend());
  533. return static_cast<number<B, et_off>&&>(a);
  534. }
  535. template <class B, class V>
  536. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  537. operator ^ (number<B, et_off>&& a, const V& b)
  538. {
  539. using default_ops::eval_bitwise_xor;
  540. eval_bitwise_xor(a.backend(), number<B, et_off>::canonical_value(b));
  541. return static_cast<number<B, et_off>&&>(a);
  542. }
  543. template <class V, class B>
  544. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  545. operator ^ (const V& a, number<B, et_off>&& b)
  546. {
  547. using default_ops::eval_bitwise_xor;
  548. eval_bitwise_xor(b.backend(), number<B, et_off>::canonical_value(a));
  549. return static_cast<number<B, et_off>&&>(b);
  550. }
  551. //
  552. // Bitwise and:
  553. //
  554. template <class B>
  555. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator & (number<B, et_off>&& a, const number<B, et_off>& b)
  556. {
  557. using default_ops::eval_bitwise_and;
  558. eval_bitwise_and(a.backend(), b.backend());
  559. return static_cast<number<B, et_off>&&>(a);
  560. }
  561. template <class B>
  562. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator & (const number<B, et_off>& a, number<B, et_off>&& b)
  563. {
  564. using default_ops::eval_bitwise_and;
  565. eval_bitwise_and(b.backend(), a.backend());
  566. return static_cast<number<B, et_off>&&>(b);
  567. }
  568. template <class B>
  569. BOOST_MP_FORCEINLINE typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, et_off> >::type operator & (number<B, et_off>&& a, number<B, et_off>&& b)
  570. {
  571. using default_ops::eval_bitwise_and;
  572. eval_bitwise_and(a.backend(), b.backend());
  573. return static_cast<number<B, et_off>&&>(a);
  574. }
  575. template <class B, class V>
  576. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  577. operator & (number<B, et_off>&& a, const V& b)
  578. {
  579. using default_ops::eval_bitwise_and;
  580. eval_bitwise_and(a.backend(), number<B, et_off>::canonical_value(b));
  581. return static_cast<number<B, et_off>&&>(a);
  582. }
  583. template <class V, class B>
  584. BOOST_MP_FORCEINLINE typename enable_if_c<is_compatible_arithmetic_type<V, number<B, et_off> >::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  585. operator & (const V& a, number<B, et_off>&& b)
  586. {
  587. using default_ops::eval_bitwise_and;
  588. eval_bitwise_and(b.backend(), number<B, et_off>::canonical_value(a));
  589. return static_cast<number<B, et_off>&&>(b);
  590. }
  591. //
  592. // shifts:
  593. //
  594. template <class B, class I>
  595. BOOST_MP_FORCEINLINE typename enable_if_c<is_integral<I>::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  596. operator << (number<B, et_off>&& a, const I& b)
  597. {
  598. using default_ops::eval_left_shift;
  599. eval_left_shift(a.backend(), b);
  600. return static_cast<number<B, et_off>&&>(a);
  601. }
  602. template <class B, class I>
  603. BOOST_MP_FORCEINLINE typename enable_if_c<is_integral<I>::value && (number_category<B>::value == number_kind_integer), number<B, et_off> >::type
  604. operator >> (number<B, et_off>&& a, const I& b)
  605. {
  606. using default_ops::eval_right_shift;
  607. eval_right_shift(a.backend(), b);
  608. return static_cast<number<B, et_off>&&>(a);
  609. }
  610. #endif
  611. }} // namespaces
  612. #ifdef BOOST_MSVC
  613. #pragma warning(pop)
  614. #endif
  615. #endif // BOOST_MP_NO_ET_OPS_HPP