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/automatic.hpp>
11 #include "test_add_automatic_results.hpp"
12
13 template <class T>
14 using safe_t = boost::safe_numerics::safe<
15 T,
16 boost::safe_numerics::automatic
17 >;
18
19 #include "test_add_constexpr.hpp"
20
21 using namespace boost::mp11;
22
23 template<typename First, typename Second>
24 struct test_pair {
25 static const std::size_t i = First();
26 static const std::size_t j = Second();
27 constexpr static const bool value = test_add_constexpr(
28 typename boost::mp11::mp_at_c<test_values, i>()(),
29 typename boost::mp11::mp_at_c<test_values, j>()(),
30 test_addition_automatic_result[i][j]
31 );
32 };
33
34 #include <boost/mp11/list.hpp>
35 #include <boost/mp11/algorithm.hpp>
36 #include "check_symmetry.hpp"
37
main()38 int main(){
39 using namespace boost::mp11;
40
41 // sanity check on test matrix - should be symetrical
42 check_symmetry(test_addition_automatic_result);
43
44 using value_indices = mp_iota_c<mp_size<test_values>::value>;
45
46 static_assert(
47 mp_all_of<
48 mp_product<
49 test_pair,
50 value_indices,
51 value_indices
52 >,
53 mp_to_bool
54 >(),
55 "all values for all integer types correctly added"
56 );
57 return 0;
58 }
59