]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/mp_valid.cpp
2 // Copyright 2015 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/core/lightweight_test_trait.hpp>
13 template<class T
> struct Xi
17 template<> struct Xi
<void>
22 template<class T
> using X
= typename Xi
<T
>::type
;
24 template<class T
> using add_pointer
= T
*;
25 template<class T
> using add_reference
= T
&;
26 template<class T
> using add_extents
= T
[];
28 using boost::mp11::mp_quote
;
30 using QX
= mp_quote
<X
>;
31 using Q_add_pointer
= mp_quote
<add_pointer
>;
35 using boost::mp11::mp_valid
;
36 using boost::mp11::mp_identity
;
38 BOOST_TEST_TRAIT_FALSE((mp_valid
<mp_identity
>));
39 BOOST_TEST_TRAIT_TRUE((mp_valid
<mp_identity
, void>));
40 BOOST_TEST_TRAIT_FALSE((mp_valid
<mp_identity
, void, void>));
42 BOOST_TEST_TRAIT_FALSE((mp_valid
<X
>));
43 BOOST_TEST_TRAIT_TRUE((mp_valid
<X
, void>));
44 BOOST_TEST_TRAIT_FALSE((mp_valid
<X
, int>));
45 BOOST_TEST_TRAIT_FALSE((mp_valid
<X
, void, void>));
47 BOOST_TEST_TRAIT_FALSE((mp_valid
<QX::fn
>));
48 BOOST_TEST_TRAIT_TRUE((mp_valid
<QX::fn
, void>));
49 BOOST_TEST_TRAIT_FALSE((mp_valid
<QX::fn
, int>));
50 BOOST_TEST_TRAIT_FALSE((mp_valid
<QX::fn
, void, void>));
52 BOOST_TEST_TRAIT_FALSE((mp_valid
<add_pointer
>));
53 BOOST_TEST_TRAIT_TRUE((mp_valid
<add_pointer
, void>));
54 BOOST_TEST_TRAIT_TRUE((mp_valid
<add_pointer
, int>));
55 #if !defined( BOOST_MSVC ) || !BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
56 // msvc-12.0 can form pointer to reference
57 BOOST_TEST_TRAIT_FALSE((mp_valid
<add_pointer
, int&>));
59 BOOST_TEST_TRAIT_FALSE((mp_valid
<add_pointer
, void, void>));
61 BOOST_TEST_TRAIT_FALSE((mp_valid
<Q_add_pointer::fn
>));
62 BOOST_TEST_TRAIT_TRUE((mp_valid
<Q_add_pointer::fn
, void>));
63 BOOST_TEST_TRAIT_TRUE((mp_valid
<Q_add_pointer::fn
, int>));
64 BOOST_TEST_TRAIT_FALSE((mp_valid
<Q_add_pointer::fn
, void, void>));
66 #if !defined( BOOST_GCC ) || !BOOST_WORKAROUND( BOOST_GCC, < 70000 )
67 // g++ up to at least 6.3 doesn't like add_reference for some reason or other
68 BOOST_TEST_TRAIT_FALSE((mp_valid
<add_reference
>));
69 #if !defined( BOOST_MSVC ) || !BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
70 // msvc-12.0 gives an internal error here
71 BOOST_TEST_TRAIT_FALSE((mp_valid
<add_reference
, void>));
73 BOOST_TEST_TRAIT_TRUE((mp_valid
<add_reference
, int>));
74 BOOST_TEST_TRAIT_FALSE((mp_valid
<add_reference
, int, int>));
77 BOOST_TEST_TRAIT_FALSE((mp_valid
<add_extents
>));
78 BOOST_TEST_TRAIT_TRUE((mp_valid
<add_extents
, int>));
79 #if !defined( BOOST_MSVC ) || !BOOST_WORKAROUND( BOOST_MSVC, <= 1800 )
80 // msvc-12.0 can form arrays to void or int&
81 BOOST_TEST_TRAIT_FALSE((mp_valid
<add_extents
, void>));
82 BOOST_TEST_TRAIT_FALSE((mp_valid
<add_extents
, int&>));
84 BOOST_TEST_TRAIT_FALSE((mp_valid
<add_extents
, int, int>));
86 return boost::report_errors();