]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/mp_invoke.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / mp11 / test / mp_invoke.cpp
1
2 // Copyright 2015, 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/mp11/integral.hpp>
12 #include <boost/core/lightweight_test_trait.hpp>
13 #include <type_traits>
14
15 using boost::mp11::mp_invoke;
16 using boost::mp11::mp_size_t;
17
18 struct Q1
19 {
20 template<class...> using fn = void;
21 };
22
23 struct Q2
24 {
25 template<class...> class fn;
26 };
27
28 struct Q3
29 {
30 template<class... T> using fn = mp_size_t<sizeof...(T)>;
31 };
32
33 struct Q4
34 {
35 template<class T1, class... T> using fn = T1;
36 };
37
38 struct Q5
39 {
40 template<class T1, class T2> using fn = T2;
41 };
42
43 int main()
44 {
45 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q1>, void>));
46 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q1, int>, void>));
47 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q1, int[], char[]>, void>));
48
49 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q2>, Q2::fn<>>));
50 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q2, int>, Q2::fn<int>>));
51 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q2, int[], char[]>, Q2::fn<int[], char[]>>));
52
53 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q3>, mp_size_t<0>>));
54 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q3, int>, mp_size_t<1>>));
55 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q3, int[], char[]>, mp_size_t<2>>));
56
57 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q4, int>, int>));
58 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q4, int[], char[]>, int[]>));
59
60 BOOST_TEST_TRAIT_TRUE((std::is_same<mp_invoke<Q5, int, float>, float>));
61
62 return boost::report_errors();
63 }