]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/mp_defer.cpp
2 // Copyright 2015-2017 Peter Dimov.
4 // Distributed under the Boost Software License, Version 1.0.
6 // See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt
10 #include <boost/mp11/utility.hpp>
11 #include <boost/mp11/integral.hpp>
12 #include <boost/core/lightweight_test_trait.hpp>
13 #include <type_traits>
15 using boost::mp11::mp_identity
;
16 using boost::mp11::mp_true
;
17 using boost::mp11::mp_false
;
19 template<class T
> struct has_type
21 template<class U
> static mp_true
f( mp_identity
<typename
U::type
>* );
22 template<class U
> static mp_false
f( ... );
24 using type
= decltype( f
<T
>(0) );
26 static const bool value
= type::value
;
29 using boost::mp11::mp_defer
;
31 template<class T
> using add_pointer
= T
*;
32 template<class... T
> using add_pointer_impl
= mp_defer
<add_pointer
, T
...>;
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*>));
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*>));
42 BOOST_TEST_TRAIT_FALSE((has_type
<add_pointer_impl
<>>));
43 BOOST_TEST_TRAIT_FALSE((has_type
<add_pointer_impl
<void, void>>));
45 return boost::report_errors();