]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mp11/test/mp_valid.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / mp11 / test / mp_valid.cpp
1
2 // Copyright 2015 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/core/lightweight_test_trait.hpp>
12
13 template<class T> struct Xi
14 {
15 };
16
17 template<> struct Xi<void>
18 {
19 using type = void;
20 };
21
22 template<class T> using X = typename Xi<T>::type;
23
24 template<class T> using add_pointer = T*;
25 template<class T> using add_reference = T&;
26 template<class T> using add_extents = T[];
27
28 using boost::mp11::mp_quote;
29
30 using QX = mp_quote<X>;
31 using Q_add_pointer = mp_quote<add_pointer>;
32
33 int main()
34 {
35 using boost::mp11::mp_valid;
36 using boost::mp11::mp_identity;
37
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>));
41
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>));
46
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>));
51
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&>));
58 #endif
59 BOOST_TEST_TRAIT_FALSE((mp_valid<add_pointer, void, void>));
60
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>));
65
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>));
72 #endif
73 BOOST_TEST_TRAIT_TRUE((mp_valid<add_reference, int>));
74 BOOST_TEST_TRAIT_FALSE((mp_valid<add_reference, int, int>));
75 #endif
76
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&>));
83 #endif
84 BOOST_TEST_TRAIT_FALSE((mp_valid<add_extents, int, int>));
85
86 return boost::report_errors();
87 }