• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright 2017 Peter Dimov.
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 //
6 // See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt
8 
9 
10 #include <boost/mp11/algorithm.hpp>
11 #include <boost/mp11/integral.hpp>
12 #include <boost/mp11/integer_sequence.hpp>
13 #include <boost/core/lightweight_test_trait.hpp>
14 #include <type_traits>
15 
16 template<class T, T... I> struct S;
17 
main()18 int main()
19 {
20     using boost::mp11::mp_list;
21     using boost::mp11::mp_from_sequence;
22     using boost::mp11::mp_int;
23     using boost::mp11::mp_size_t;
24     using boost::mp11::make_integer_sequence;
25     using boost::mp11::make_index_sequence;
26 
27     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<S<int>>, mp_list<>>));
28     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<S<int, 1>>, mp_list<mp_int<1>>>));
29     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<S<int, 1, 3>>, mp_list<mp_int<1>, mp_int<3>>>));
30     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<S<int, 1, 3, 5>>, mp_list<mp_int<1>, mp_int<3>, mp_int<5>>>));
31 
32     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_integer_sequence<int, 0>>, mp_list<>>));
33     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_integer_sequence<int, 1>>, mp_list<mp_int<0>>>));
34     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_integer_sequence<int, 2>>, mp_list<mp_int<0>, mp_int<1>>>));
35     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_integer_sequence<int, 3>>, mp_list<mp_int<0>, mp_int<1>, mp_int<2>>>));
36 
37     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_index_sequence<0>>, mp_list<>>));
38     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_index_sequence<1>>, mp_list<mp_size_t<0>>>));
39     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_index_sequence<2>>, mp_list<mp_size_t<0>, mp_size_t<1>>>));
40     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_from_sequence<make_index_sequence<3>>, mp_list<mp_size_t<0>, mp_size_t<1>, mp_size_t<2>>>));
41 
42     return boost::report_errors();
43 }
44