]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/test/is_list_constructible_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / type_traits / test / is_list_constructible_test.cpp
1
2 // Copyright 2017 Peter Dimov
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7
8 #if defined( __GNUC__ ) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 407)
9 #pragma GCC diagnostic ignored "-Wnarrowing"
10 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
11 #endif
12
13 #ifdef TEST_STD
14 # include <type_traits>
15 #else
16 # include <boost/type_traits/is_list_constructible.hpp>
17 #endif
18 #include "test.hpp"
19 #include "check_integral_constant.hpp"
20
21 #if defined(BOOST_NO_SFINAE_EXPR) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_DECLTYPE) \
22 || defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) || defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)\
23 || BOOST_WORKAROUND(BOOST_GCC, < 40700)
24
25 int main() {}
26
27 #else
28
29 #include <vector>
30
31 struct X
32 {
33 int a;
34 int b;
35 };
36
37 struct Y
38 {
39 Y( int = 0, int = 0 );
40 };
41
42 struct Z
43 {
44 explicit Z( int = 0, int = 0 );
45 };
46
47 struct V
48 {
49 V( int&, int& );
50 };
51
52 TT_TEST_BEGIN(is_list_constructible)
53
54 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<int>::value), true);
55 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<int, int>::value), true);
56 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<int, int const>::value), true);
57 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<int, int, int>::value), false);
58 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<int, char>::value), true);
59
60 #if defined(CI_SUPPRESS_KNOWN_ISSUES) && defined(__GNUC__) && (__GNUC__ == 4)
61 // g++ 4.x doesn't seem to disallow narrowing
62 #else
63 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<int, float>::value), false);
64 #endif
65
66 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<X>::value), true);
67 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<X, int>::value), true);
68 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<X, int const>::value), true);
69 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<X, int, int>::value), true);
70 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<X, int const, int const>::value), true);
71 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<X, int, int, int>::value), false);
72
73 #if defined(CI_SUPPRESS_KNOWN_ISSUES) && defined(__GNUC__) && (__GNUC__ == 4)
74 // g++ 4.x doesn't seem to disallow narrowing
75 #else
76 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<X, float>::value), false);
77 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<X, int, float>::value), false);
78 #endif
79
80 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Y>::value), true);
81 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Y, int>::value), true);
82 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Y, int const>::value), true);
83 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Y, int, int>::value), true);
84 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Y, int const, int const>::value), true);
85 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Y, int, int, int>::value), false);
86
87 #if defined(CI_SUPPRESS_KNOWN_ISSUES) && defined(__GNUC__) && (__GNUC__ == 4)
88 // g++ 4.x doesn't seem to disallow narrowing
89 #elif defined(CI_SUPPRESS_KNOWN_ISSUES) && defined(__GNUC__) && (__GNUC__ == 7) && (__cplusplus >= 201500)
90 // g++ 7.1 in -std=c++1z, c++17 has a bug
91 #elif defined(__NVCC__)
92 // nvcc in -std=c++17 mode has this issue.
93 #else
94 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Y, float>::value), false);
95 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Y, int, float>::value), false);
96 #endif
97
98 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Z>::value), true);
99 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Z, int>::value), true);
100 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Z, int const>::value), true);
101 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Z, int, int>::value), true);
102 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Z, int const, int const>::value), true);
103 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Z, int, int, int>::value), false);
104
105 #if defined(CI_SUPPRESS_KNOWN_ISSUES) && defined(__GNUC__) && (__GNUC__ == 4)
106 // g++ 4.x doesn't seem to disallow narrowing
107 #elif defined(CI_SUPPRESS_KNOWN_ISSUES) && defined(__GNUC__) && (__GNUC__ == 7) && (__cplusplus >= 201500)
108 // g++ 7.1 in -std=c++1z, c++17 has a bug
109 #elif defined(__NVCC__)
110 // nvcc in -std=c++17 mode has this issue.
111 #else
112 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Z, float>::value), false);
113 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<Z, int, float>::value), false);
114 #endif
115
116 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<V>::value), false);
117 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<V, int>::value), false);
118 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<V, int, int>::value), false);
119 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<V, int, int, int>::value), false);
120 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<V, int&, int&>::value), true);
121 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_list_constructible<V, int const&, int const&>::value), false);
122
123 TT_TEST_END
124
125 #endif