• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright 2017, 2020 Peter Dimov.
3 // Distributed under the Boost Software License, Version 1.0.
4 // https://www.boost.org/LICENSE_1_0.txt
5 
6 
7 #include <boost/mp11/utility.hpp>
8 #include <boost/core/lightweight_test_trait.hpp>
9 
10 template<class T> struct F1 {};
11 template<class T> struct F2 {};
12 template<class T> struct F3 {};
13 
14 template<class T> using G1 = F1<T>;
15 template<class T> using G2 = F2<T>;
16 template<class T> using G3 = F3<T>;
17 
main()18 int main()
19 {
20     using namespace boost::mp11;
21 
22 #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 )
23 
24     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<>::fn<void>, void>));
25 
26     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<F1>::fn<void>, F1<void>>));
27     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<G1>::fn<void>, F1<void>>));
28 
29     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<F1, F2>::fn<void>, F2<F1<void>>>));
30     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<G1, G2>::fn<void>, F2<F1<void>>>));
31 
32     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<F1, F2, F3>::fn<void>, F3<F2<F1<void>>>>));
33     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose<G1, G2, G3>::fn<void>, F3<F2<F1<void>>>>));
34 
35 #endif
36 
37     using QF1 = mp_quote<F1>;
38     using QF2 = mp_quote<F2>;
39     using QF3 = mp_quote<F3>;
40 
41     using QG1 = mp_quote<G1>;
42     using QG2 = mp_quote<G2>;
43     using QG3 = mp_quote<G3>;
44 
45     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<>::fn<void>, void>));
46 
47     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QF1>::fn<void>, F1<void>>));
48     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QG1>::fn<void>, F1<void>>));
49 
50     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QF1, QF2>::fn<void>, F2<F1<void>>>));
51     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QG1, QG2>::fn<void>, F2<F1<void>>>));
52 
53     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QF1, QF2, QF3>::fn<void>, F3<F2<F1<void>>>>));
54     BOOST_TEST_TRAIT_TRUE((std::is_same<mp_compose_q<QG1, QG2, QG3>::fn<void>, F3<F2<F1<void>>>>));
55 
56     //
57 
58     return boost::report_errors();
59 }
60