]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/safe_numerics/test/test_add_native_constexpr.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / safe_numerics / test / test_add_native_constexpr.cpp
1 // Copyright (c) 2019 Robert Ramey
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 #include <boost/safe_numerics/safe_integer.hpp>
8 #include <boost/safe_numerics/native.hpp>
9
10 #include "test_add_native_results.hpp"
11
12 template <class T>
13 using safe_t = boost::safe_numerics::safe<
14 T,
15 boost::safe_numerics::native
16 >;
17
18 #include "test_add_constexpr.hpp"
19
20 using namespace boost::mp11;
21
22 template<typename First, typename Second>
23 struct test_pair {
24 static const std::size_t i = First();
25 static const std::size_t j = Second();
26 constexpr static const bool value = test_add_constexpr(
27 mp_at_c<test_values, i>()(),
28 mp_at_c<test_values, j>()(),
29 test_addition_native_result[i][j]
30 );
31 };
32
33 #include <boost/mp11/list.hpp>
34 #include <boost/mp11/algorithm.hpp>
35 #include "check_symmetry.hpp"
36
37 int main(){
38 using namespace boost::mp11;
39
40 static_assert(
41 check_symmetry(test_addition_native_result),
42 "sanity check on test matrix - should be symmetrical"
43 );
44
45 using value_indices = mp_iota_c<mp_size<test_values>::value>;
46
47 static_assert(
48 mp_all_of<
49 mp_product<
50 test_pair,
51 value_indices,
52 value_indices
53 >,
54 mp_to_bool
55 >(),
56 "all values for all integer types correctly added"
57 );
58 return 0;
59 }