1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // type_traits
10
11 // template <class T, class... Args>
12 // struct is_trivially_constructible;
13
14 #include <type_traits>
15 #include "test_macros.h"
16
17 template <class T>
test_is_trivially_constructible()18 void test_is_trivially_constructible()
19 {
20 static_assert(( std::is_trivially_constructible<T>::value), "");
21 #if TEST_STD_VER > 14
22 static_assert(( std::is_trivially_constructible_v<T>), "");
23 #endif
24 }
25
26 template <class T, class A0>
test_is_trivially_constructible()27 void test_is_trivially_constructible()
28 {
29 static_assert(( std::is_trivially_constructible<T, A0>::value), "");
30 #if TEST_STD_VER > 14
31 static_assert(( std::is_trivially_constructible_v<T, A0>), "");
32 #endif
33 }
34
35 template <class T>
test_is_not_trivially_constructible()36 void test_is_not_trivially_constructible()
37 {
38 static_assert((!std::is_trivially_constructible<T>::value), "");
39 #if TEST_STD_VER > 14
40 static_assert((!std::is_trivially_constructible_v<T>), "");
41 #endif
42 }
43
44 template <class T, class A0>
test_is_not_trivially_constructible()45 void test_is_not_trivially_constructible()
46 {
47 static_assert((!std::is_trivially_constructible<T, A0>::value), "");
48 #if TEST_STD_VER > 14
49 static_assert((!std::is_trivially_constructible_v<T, A0>), "");
50 #endif
51 }
52
53 template <class T, class A0, class A1>
test_is_not_trivially_constructible()54 void test_is_not_trivially_constructible()
55 {
56 static_assert((!std::is_trivially_constructible<T, A0, A1>::value), "");
57 #if TEST_STD_VER > 14
58 static_assert((!std::is_trivially_constructible_v<T, A0, A1>), "");
59 #endif
60 }
61
62 struct A
63 {
64 explicit A(int);
65 A(int, double);
66 };
67
main(int,char **)68 int main(int, char**)
69 {
70 test_is_trivially_constructible<int> ();
71 test_is_trivially_constructible<int, const int&> ();
72
73 test_is_not_trivially_constructible<A, int> ();
74 test_is_not_trivially_constructible<A, int, double> ();
75 test_is_not_trivially_constructible<A> ();
76
77 return 0;
78 }
79