]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/multiprecision/test/constexpr_test_arithmetic_backend.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / multiprecision / test / constexpr_test_arithmetic_backend.cpp
1 // (C) Copyright John Maddock 2019.
2 // Use, modification and distribution are subject to the
3 // Boost 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 "constexpr_arithmetric_test.hpp"
7 #include "../performance/arithmetic_backend.hpp"
8
9 int main()
10 {
11 typedef boost::multiprecision::number<boost::multiprecision::backends::arithmetic_backend<long long>, boost::multiprecision::et_off> int_backend;
12 typedef boost::multiprecision::number<boost::multiprecision::backends::arithmetic_backend<unsigned long long>, boost::multiprecision::et_off> unsigned_backend;
13
14 typedef boost::multiprecision::number<boost::multiprecision::backends::arithmetic_backend<long long>, boost::multiprecision::et_on> int_backend_et;
15 typedef boost::multiprecision::number<boost::multiprecision::backends::arithmetic_backend<unsigned long long>, boost::multiprecision::et_on> unsigned_backend_et;
16
17 {
18 constexpr int_backend a(22);
19 constexpr unsigned_backend c(22);
20 constexpr int_backend b = test_constexpr_add_subtract(a);
21 constexpr unsigned_backend d = test_constexpr_add_subtract(c);
22
23 constexpr long long llv = (long long)b;
24
25 static_assert(b == -108);
26 static_assert(d == 554);
27 }
28 {
29 constexpr int_backend a(22);
30 constexpr unsigned_backend c(22);
31 constexpr int_backend b = test_constexpr_mul_divide(a);
32 constexpr unsigned_backend d = test_constexpr_mul_divide(c);
33 static_assert(b == 22);
34 static_assert(d == 22);
35 }
36 {
37 constexpr int_backend a(22);
38 constexpr unsigned_backend c(22);
39 constexpr int_backend b = test_constexpr_bitwise(a);
40 constexpr unsigned_backend d = test_constexpr_bitwise(c);
41 #ifdef BOOST_HAS_INT128
42 static_assert(b == 230);
43 static_assert(d == 120);
44 #else
45 static_assert(b == 210);
46 static_assert(d == 106);
47 #endif
48 }
49 {
50 constexpr int_backend a(22);
51 constexpr unsigned_backend c(22);
52 constexpr int_backend b = test_constexpr_logical(a);
53 constexpr unsigned_backend d = test_constexpr_logical(c);
54 static_assert(b == 82);
55 static_assert(d == 82);
56 }
57 {
58 constexpr int_backend a(22);
59 constexpr unsigned_backend c(22);
60 constexpr int_backend b = test_constexpr_compare(a);
61 constexpr unsigned_backend d = test_constexpr_compare(c);
62 static_assert(b == 95);
63 static_assert(d == 95);
64 }
65 //
66 // Over again with expression templates turned on:
67 //
68 {
69 constexpr int_backend_et a(22);
70 constexpr unsigned_backend_et c(22);
71 constexpr int_backend_et b = test_constexpr_add_subtract(a);
72 constexpr unsigned_backend_et d = test_constexpr_add_subtract(c);
73
74 static_assert(b == -108);
75 static_assert(d == 554);
76 }
77 {
78 constexpr int_backend_et a(22);
79 constexpr unsigned_backend_et c(22);
80 constexpr int_backend_et b = test_constexpr_mul_divide(a);
81 constexpr unsigned_backend_et d = test_constexpr_mul_divide(c);
82 static_assert(b == 22);
83 static_assert(d == 22);
84 }
85 {
86 constexpr int_backend_et a(22);
87 constexpr unsigned_backend_et c(22);
88 constexpr int_backend_et b = test_constexpr_bitwise(a);
89 constexpr unsigned_backend_et d = test_constexpr_bitwise(c);
90 #ifdef BOOST_HAS_INT128
91 static_assert(b == 230);
92 static_assert(d == 120);
93 #else
94 static_assert(b == 210);
95 static_assert(d == 106);
96 #endif
97 }
98 {
99 constexpr int_backend_et a(22);
100 constexpr unsigned_backend_et c(22);
101 constexpr int_backend_et b = test_constexpr_logical(a);
102 constexpr unsigned_backend_et d = test_constexpr_logical(c);
103 static_assert(b == 82);
104 static_assert(d == 82);
105 }
106 {
107 constexpr int_backend_et a(22);
108 constexpr unsigned_backend_et c(22);
109 constexpr int_backend_et b = test_constexpr_compare(a);
110 constexpr unsigned_backend_et d = test_constexpr_compare(c);
111 static_assert(b == 95);
112 static_assert(d == 95);
113 }
114 std::cout << "Done!" << std::endl;
115 }