]>
git.proxmox.com Git - ceph.git/blob - 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)
6 #include "constexpr_arithmetric_test.hpp"
7 #include "../performance/arithmetic_backend.hpp"
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
;
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
;
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
);
23 constexpr long long llv
= ( long long ) b
;
25 static_assert ( b
== - 108 );
26 static_assert ( d
== 554 );
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 );
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 );
45 static_assert ( b
== 210 );
46 static_assert ( d
== 106 );
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 );
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 );
66 // Over again with expression templates turned on:
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
);
74 static_assert ( b
== - 108 );
75 static_assert ( d
== 554 );
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 );
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 );
94 static_assert ( b
== 210 );
95 static_assert ( d
== 106 );
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 );
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 );
114 std :: cout
<< "Done!" << std :: endl
;