]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/safe_numerics/test/test_multiply_native_constexpr.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / safe_numerics / test / test_multiply_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 #include "test_multiply_native_results.hpp"
10
11 template <class T>
12 using safe_t = boost::safe_numerics::safe<
13 T,
14 boost::safe_numerics::native
15 >;
16
17 #include "test_multiply_constexpr.hpp"
18
19 using namespace boost::mp11;
20
21 template<typename First, typename Second>
22 struct test_pair {
23 static const std::size_t i = First();
24 static const std::size_t j = Second();
25 constexpr static const bool value = test_multiply_constexpr(
26 mp_at_c<test_values, i>()(),
27 mp_at_c<test_values, j>()(),
28 test_multiplication_native_result[i][j]
29 );
30 };
31
32 #include <boost/mp11/list.hpp>
33 #include <boost/mp11/algorithm.hpp>
34 #include "check_symmetry.hpp"
35
36 int main(){
37 using namespace boost::mp11;
38
39 // sanity check on test matrix - should be symetrical
40 check_symmetry(test_multiplication_native_result);
41
42 using value_indices = mp_iota_c<mp_size<test_values>::value>;
43
44 static_assert(
45 mp_all_of<
46 mp_product<
47 test_pair,
48 value_indices,
49 value_indices
50 >,
51 mp_to_bool
52 >(),
53 "all values for all integer types correctly multiplied"
54 );
55 return 0;
56 }