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 <iostream
8 
9 #include <boost/safe_numerics/safe_integer.hpp>
10 #include <boost/safe_numerics/native.hpp>
11 
12 #include "test_add_native_results.hpp"
13 
14 template <class T>
15 using safe_t = boost::safe_numerics::safe<
16     T,
17     boost::safe_numerics::native
18 >;
19 
20 #include "test_add_constexpr.hpp"
21 
22 using namespace boost::mp11;
23 
24 template<typename First, typename Second>
25 struct test_pair {
26     static const std::size_t i = First();
27     static const std::size_t j = Second();
28     constexpr static const bool value = test_add_constexpr(
29         typename boost::mp11::mp_at_c<test_values, i>()(),
30         typename boost::mp11::mp_at_c<test_values, j>()(),
31         test_addition_native_result[i][j]
32     );
33 };
34 
35 #include <boost/mp11/list.hpp>
36 #include <boost/mp11/algorithm.hpp>
37 #include "check_symmetry.hpp"
38 
main()39 int main(){
40     using namespace boost::mp11;
41 
42     // sanity check on test matrix - should be symetrical
43     check_symmetry(test_addition_native_result);
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 }
60