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