]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/test/is_constructible_test.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / type_traits / test / is_constructible_test.cpp
1
2 // (C) Copyright John Maddock 2000.
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 #ifdef TEST_STD
8 # include <type_traits>
9 #else
10 # include <boost/type_traits/is_constructible.hpp>
11 #endif
12 #include "test.hpp"
13 #include "check_integral_constant.hpp"
14
15
16 struct non_copy_constructible
17 {
18 non_copy_constructible();
19 non_copy_constructible(int);
20 non_copy_constructible(double*, double*);
21 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
22 non_copy_constructible(const non_copy_constructible&) = delete;
23 #endif
24 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
25 non_copy_constructible(non_copy_constructible&&);
26 #endif
27 };
28
29
30 struct A { };
31 struct B : A { };
32
33 TT_TEST_BEGIN(is_constructible)
34
35 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
36 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B &&, A>::value) , false);
37 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B const &&, A>::value) , false);
38 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B const &&, A const>::value) , false);
39 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B volatile &&, A>::value) , false);
40 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B volatile &&, A volatile>::value) , false);
41 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B const volatile &&, A>::value) , false);
42 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B const volatile &&, A const>::value) , false);
43 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B const volatile &&, A volatile>::value) , false);
44 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B const volatile &&, A const volatile>::value) , false);
45 #endif
46 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B&, A>::value), false);
47 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B const &, A>::value), false);
48 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B const &, A&>::value), false);
49 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<B const &, A const>::value), false);
50
51 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible<non_copy_constructible>::value), true, false);
52 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible<non_copy_constructible, int>::value), true, false);
53 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible<non_copy_constructible, int const>::value), true, false);
54 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible<non_copy_constructible, int const&>::value), true, false);
55 #if !BOOST_WORKAROUND(BOOST_GCC, < 40500)
56 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible<non_copy_constructible, non_copy_constructible>::value), true, false);
57 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800)
58 BOOST_CHECK_SOFT_INTEGRAL_CONSTANT((::tt::is_constructible<non_copy_constructible, double*, double*>::value), true, false);
59 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<non_copy_constructible, double const*, double*>::value), false);
60 #endif
61 #ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS
62 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<non_copy_constructible, const non_copy_constructible&>::value), false);
63 #endif
64 #endif
65
66 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int, const int>::value), true);
67 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int, const int&>::value), true);
68 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int*, const int&>::value), false);
69 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int*, const int*>::value), false);
70 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int*, int*>::value), true);
71 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int*, int[2]>::value), true);
72 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int*, int[]>::value), true);
73
74 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int(*)(int), int&>::value), false);
75 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int(*)(int), int(*)(int)>::value), true);
76 #if !(defined(CI_SUPPRESS_KNOWN_ISSUES) && BOOST_WORKAROUND(BOOST_GCC, < 40700))
77 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int(&)(int), int(int)>::value), true);
78 #endif
79 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int(int), int(int)>::value), false);
80 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_constructible<int(int), int(&)(int)>::value), false);
81
82 TT_TEST_END
83