1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // type_traits
11
12 // template <class T, class... Args>
13 // struct is_constructible;
14
15 #include <type_traits>
16
17 struct A
18 {
19 explicit A(int);
20 A(int, double);
21 #if __has_feature(cxx_access_control_sfinae)
22 private:
23 #endif
24 A(char);
25 };
26
27 class Abstract
28 {
29 virtual void foo() = 0;
30 };
31
32 class AbstractDestructor
33 {
34 virtual ~AbstractDestructor() = 0;
35 };
36
37 template <class T>
test_is_constructible()38 void test_is_constructible()
39 {
40 static_assert( (std::is_constructible<T>::value), "");
41 }
42
43 template <class T, class A0>
test_is_constructible()44 void test_is_constructible()
45 {
46 static_assert( (std::is_constructible<T, A0>::value), "");
47 }
48
49 template <class T, class A0, class A1>
test_is_constructible()50 void test_is_constructible()
51 {
52 static_assert( (std::is_constructible<T, A0, A1>::value), "");
53 }
54
55 template <class T>
test_is_not_constructible()56 void test_is_not_constructible()
57 {
58 static_assert((!std::is_constructible<T>::value), "");
59 }
60
61 template <class T, class A0>
test_is_not_constructible()62 void test_is_not_constructible()
63 {
64 static_assert((!std::is_constructible<T, A0>::value), "");
65 }
66
main()67 int main()
68 {
69 test_is_constructible<int> ();
70 test_is_constructible<int, const int> ();
71 test_is_constructible<A, int> ();
72 test_is_constructible<A, int, double> ();
73 test_is_constructible<int&, int&> ();
74
75 test_is_not_constructible<A> ();
76 #if __has_feature(cxx_access_control_sfinae)
77 test_is_not_constructible<A, char> ();
78 #else
79 test_is_constructible<A, char> ();
80 #endif
81 test_is_not_constructible<A, void> ();
82 test_is_not_constructible<void> ();
83 test_is_not_constructible<int&> ();
84 test_is_not_constructible<Abstract> ();
85 test_is_not_constructible<AbstractDestructor> ();
86 }
87