]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mp11/test/mp_valid.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / mp11 / test / mp_valid.cpp
CommitLineData
b32b8144
FG
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>
92f5a8d4 11#include <boost/mp11/detail/config.hpp>
b32b8144
FG
12#include <boost/core/lightweight_test_trait.hpp>
13
14template<class T> struct Xi
15{
16};
17
18template<> struct Xi<void>
19{
20 using type = void;
21};
22
23template<class T> using X = typename Xi<T>::type;
24
25template<class T> using add_pointer = T*;
26template<class T> using add_reference = T&;
27template<class T> using add_extents = T[];
28
11fdf7f2
TL
29using boost::mp11::mp_quote;
30
31using QX = mp_quote<X>;
32using Q_add_pointer = mp_quote<add_pointer>;
33
b32b8144
FG
34int main()
35{
36 using boost::mp11::mp_valid;
92f5a8d4 37 using boost::mp11::mp_valid_q;
b32b8144
FG
38 using boost::mp11::mp_identity;
39
40 BOOST_TEST_TRAIT_FALSE((mp_valid<mp_identity>));
41 BOOST_TEST_TRAIT_TRUE((mp_valid<mp_identity, void>));
42 BOOST_TEST_TRAIT_FALSE((mp_valid<mp_identity, void, void>));
43
44 BOOST_TEST_TRAIT_FALSE((mp_valid<X>));
45 BOOST_TEST_TRAIT_TRUE((mp_valid<X, void>));
46 BOOST_TEST_TRAIT_FALSE((mp_valid<X, int>));
47 BOOST_TEST_TRAIT_FALSE((mp_valid<X, void, void>));
48
11fdf7f2
TL
49 BOOST_TEST_TRAIT_FALSE((mp_valid<QX::fn>));
50 BOOST_TEST_TRAIT_TRUE((mp_valid<QX::fn, void>));
51 BOOST_TEST_TRAIT_FALSE((mp_valid<QX::fn, int>));
52 BOOST_TEST_TRAIT_FALSE((mp_valid<QX::fn, void, void>));
53
92f5a8d4
TL
54 BOOST_TEST_TRAIT_FALSE((mp_valid_q<QX>));
55 BOOST_TEST_TRAIT_TRUE((mp_valid_q<QX, void>));
56 BOOST_TEST_TRAIT_FALSE((mp_valid_q<QX, int>));
57 BOOST_TEST_TRAIT_FALSE((mp_valid_q<QX, void, void>));
58
b32b8144
FG
59 BOOST_TEST_TRAIT_FALSE((mp_valid<add_pointer>));
60 BOOST_TEST_TRAIT_TRUE((mp_valid<add_pointer, void>));
61 BOOST_TEST_TRAIT_TRUE((mp_valid<add_pointer, int>));
92f5a8d4 62#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 )
b32b8144
FG
63 // msvc-12.0 can form pointer to reference
64 BOOST_TEST_TRAIT_FALSE((mp_valid<add_pointer, int&>));
65#endif
66 BOOST_TEST_TRAIT_FALSE((mp_valid<add_pointer, void, void>));
67
11fdf7f2
TL
68 BOOST_TEST_TRAIT_FALSE((mp_valid<Q_add_pointer::fn>));
69 BOOST_TEST_TRAIT_TRUE((mp_valid<Q_add_pointer::fn, void>));
70 BOOST_TEST_TRAIT_TRUE((mp_valid<Q_add_pointer::fn, int>));
71 BOOST_TEST_TRAIT_FALSE((mp_valid<Q_add_pointer::fn, void, void>));
72
92f5a8d4
TL
73 BOOST_TEST_TRAIT_FALSE((mp_valid_q<Q_add_pointer>));
74 BOOST_TEST_TRAIT_TRUE((mp_valid_q<Q_add_pointer, void>));
75 BOOST_TEST_TRAIT_TRUE((mp_valid_q<Q_add_pointer, int>));
76 BOOST_TEST_TRAIT_FALSE((mp_valid_q<Q_add_pointer, void, void>));
77
78#if !BOOST_MP11_WORKAROUND( BOOST_MP11_GCC, < 70000 )
b32b8144
FG
79 // g++ up to at least 6.3 doesn't like add_reference for some reason or other
80 BOOST_TEST_TRAIT_FALSE((mp_valid<add_reference>));
92f5a8d4 81#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 )
b32b8144
FG
82 // msvc-12.0 gives an internal error here
83 BOOST_TEST_TRAIT_FALSE((mp_valid<add_reference, void>));
84#endif
85 BOOST_TEST_TRAIT_TRUE((mp_valid<add_reference, int>));
86 BOOST_TEST_TRAIT_FALSE((mp_valid<add_reference, int, int>));
87#endif
88
89 BOOST_TEST_TRAIT_FALSE((mp_valid<add_extents>));
90 BOOST_TEST_TRAIT_TRUE((mp_valid<add_extents, int>));
92f5a8d4 91#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, <= 1800 )
b32b8144
FG
92 // msvc-12.0 can form arrays to void or int&
93 BOOST_TEST_TRAIT_FALSE((mp_valid<add_extents, void>));
94 BOOST_TEST_TRAIT_FALSE((mp_valid<add_extents, int&>));
95#endif
96 BOOST_TEST_TRAIT_FALSE((mp_valid<add_extents, int, int>));
97
98 return boost::report_errors();
99}