1 // Copyright (c) 2012 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/automatic.hpp>
9
10 template <class T>
11 using safe_t = boost::safe_numerics::safe<
12 T,
13 boost::safe_numerics::automatic
14 >;
15 #include "test_xor.hpp"
16 #include "test_values.hpp"
17
18 #include <boost/mp11/algorithm.hpp>
19 #include <boost/core/demangle.hpp>
20
21 using namespace boost::mp11;
22
23 template<typename L>
24 struct test {
25 static_assert(mp_is_list<L>(), "must be a list of integral constants");
26 bool m_error;
testtest27 test(bool b = true) : m_error(b) {}
operator booltest28 operator bool(){
29 return m_error;
30 }
31 template<typename T>
operator ()test32 void operator()(const T &){
33 static_assert(mp_is_list<T>(), "must be a list of two integral constants");
34 constexpr size_t i1 = mp_first<T>(); // index of first argument
35 constexpr size_t i2 = mp_second<T>();// index of second argument
36 std::cout << i1 << ',' << i2 << ',';
37 using T1 = typename mp_at_c<L, i1>::value_type;
38 using T2 = typename mp_at_c<L, i2>::value_type;
39 m_error &= test_xor<T1, T2>(
40 mp_at_c<L, i1>()(), // value of first argument
41 mp_at_c<L, i2>()(), // value of second argument
42 boost::core::demangle(typeid(T1).name()).c_str(),
43 boost::core::demangle(typeid(T2).name()).c_str(),
44 '.'
45 );
46 }
47 };
48
main()49 int main(){
50 //TEST_EACH_VALUE_PAIR
51 test<test_values> rval(true);
52
53 using value_indices = mp_iota_c<mp_size<test_values>::value>;
54 mp_for_each<
55 mp_product<mp_list, value_indices, value_indices>
56 >(rval);
57
58 std::cout << (rval ? "success!" : "failure") << std::endl;
59 return ! rval ;
60 }
61