• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright 2019 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 <cstddef>
13 
14 template<class T> using difference_type = typename T::difference_type;
15 
16 struct X
17 {
18 };
19 
20 struct Y
21 {
22     using difference_type = int;
23 };
24 
main()25 int main()
26 {
27     using boost::mp11::mp_eval_or;
28     using boost::mp11::mp_eval_or_q;
29     using boost::mp11::mp_identity;
30     using boost::mp11::mp_quote;
31 
32     BOOST_TEST_TRAIT_SAME(mp_eval_or<void, mp_identity>, void);
33     BOOST_TEST_TRAIT_SAME(mp_eval_or<void, mp_identity, int>, mp_identity<int>);
34     BOOST_TEST_TRAIT_SAME(mp_eval_or<void, mp_identity, int, int>, void);
35 
36     using Q_identity = mp_quote<mp_identity>;
37 
38     BOOST_TEST_TRAIT_SAME(mp_eval_or_q<void, Q_identity>, void);
39     BOOST_TEST_TRAIT_SAME(mp_eval_or_q<void, Q_identity, int>, mp_identity<int>);
40     BOOST_TEST_TRAIT_SAME(mp_eval_or_q<void, Q_identity, int, int>, void);
41 
42     BOOST_TEST_TRAIT_SAME(mp_eval_or<std::ptrdiff_t, difference_type, X>, std::ptrdiff_t);
43     BOOST_TEST_TRAIT_SAME(mp_eval_or<std::ptrdiff_t, difference_type, Y>, int);
44 
45     using Q_diff_type = mp_quote<difference_type>;
46 
47     BOOST_TEST_TRAIT_SAME(mp_eval_or_q<std::ptrdiff_t, Q_diff_type, X>, std::ptrdiff_t);
48     BOOST_TEST_TRAIT_SAME(mp_eval_or_q<std::ptrdiff_t, Q_diff_type, Y>, int);
49 
50     return boost::report_errors();
51 }
52