]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/mp_defer.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / mp11 / test / mp_defer.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_identity;
16 using boost::mp11::mp_true;
17 using boost::mp11::mp_false;
18
19 template<class T> struct has_type
20 {
21 template<class U> static mp_true f( mp_identity<typename U::type>* );
22 template<class U> static mp_false f( ... );
23
24 using type = decltype( f<T>(0) );
25
26 static const bool value = type::value;
27 };
28
29 using boost::mp11::mp_defer;
30
31 template<class T> using add_pointer = T*;
32 template<class... T> using add_pointer_impl = mp_defer<add_pointer, T...>;
33
34 int main()
35 {
36 BOOST_TEST_TRAIT_TRUE((has_type<add_pointer_impl<void>>));
37 BOOST_TEST_TRAIT_TRUE((std::is_same<add_pointer_impl<void>::type, void*>));
38
39 BOOST_TEST_TRAIT_TRUE((has_type<add_pointer_impl<int>>));
40 BOOST_TEST_TRAIT_TRUE((std::is_same<add_pointer_impl<int>::type, int*>));
41
42 BOOST_TEST_TRAIT_FALSE((has_type<add_pointer_impl<>>));
43 BOOST_TEST_TRAIT_FALSE((has_type<add_pointer_impl<void, void>>));
44
45 return boost::report_errors();
46 }