• 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/utility.hpp>
11 #include <boost/core/lightweight_test_trait.hpp>
12 #include <type_traits>
13 
14 using boost::mp11::mp_eval_if;
15 using boost::mp11::mp_eval_if_q;
16 using boost::mp11::mp_identity_t;
17 using boost::mp11::mp_valid;
18 using boost::mp11::mp_quote;
19 
20 template<class C, class... A> using eval_if = mp_eval_if<C, void, mp_identity_t, A...>;
21 
main()22 int main()
23 {
24     BOOST_TEST_TRAIT_TRUE((mp_valid<eval_if, std::true_type>));
25     BOOST_TEST_TRAIT_TRUE((mp_valid<eval_if, std::true_type, void>));
26     BOOST_TEST_TRAIT_TRUE((mp_valid<eval_if, std::true_type, void, void>));
27     BOOST_TEST_TRAIT_TRUE((mp_valid<eval_if, std::true_type, void, void, void>));
28 
29     BOOST_TEST_TRAIT_FALSE((mp_valid<eval_if, std::false_type>));
30     BOOST_TEST_TRAIT_TRUE((mp_valid<eval_if, std::false_type, void>));
31     BOOST_TEST_TRAIT_FALSE((mp_valid<eval_if, std::false_type, void, void>));
32     BOOST_TEST_TRAIT_FALSE((mp_valid<eval_if, std::false_type, void, void, void>));
33 
34     using Qi = mp_quote<mp_identity_t>;
35 
36     BOOST_TEST_TRAIT_TRUE((mp_valid<mp_eval_if_q, std::true_type, void, Qi>));
37     BOOST_TEST_TRAIT_TRUE((mp_valid<mp_eval_if_q, std::true_type, void, Qi, void>));
38     BOOST_TEST_TRAIT_TRUE((mp_valid<mp_eval_if_q, std::true_type, void, Qi, void, void>));
39     BOOST_TEST_TRAIT_TRUE((mp_valid<mp_eval_if_q, std::true_type, void, Qi, void, void, void>));
40 
41     BOOST_TEST_TRAIT_FALSE((mp_valid<mp_eval_if_q, std::false_type, void, Qi>));
42     BOOST_TEST_TRAIT_TRUE((mp_valid<mp_eval_if_q, std::false_type, void, Qi, void>));
43     BOOST_TEST_TRAIT_FALSE((mp_valid<mp_eval_if_q, std::false_type, void, Qi, void, void>));
44     BOOST_TEST_TRAIT_FALSE((mp_valid<mp_eval_if_q, std::false_type, void, Qi, void, void, void>));
45 
46     return boost::report_errors();
47 }
48