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// is_trivially_copy_constructible
12
13#include <type_traits>
14#include "test_macros.h"
15
16template <class T>
17void test_is_trivially_copy_constructible()
18{
19 static_assert( std::is_trivially_copy_constructible<T>::value, "");
20 static_assert( std::is_trivially_copy_constructible<const T>::value, "");
21#if TEST_STD_VER > 14
22 static_assert( std::is_trivially_copy_constructible_v<T>, "");
23 static_assert( std::is_trivially_copy_constructible_v<const T>, "");
24#endif
25}
26
27template <class T>
28void test_has_not_trivial_copy_constructor()
29{
30 static_assert(!std::is_trivially_copy_constructible<T>::value, "");
31 static_assert(!std::is_trivially_copy_constructible<const T>::value, "");
32#if TEST_STD_VER > 14
33 static_assert(!std::is_trivially_copy_constructible_v<T>, "");
34 static_assert(!std::is_trivially_copy_constructible_v<const T>, "");
35#endif
36}
37
38class Empty
39{
40};
41
42class NotEmpty
43{
44public:
45 virtual ~NotEmpty();
46};
47
48union Union {};
49
50struct bit_zero
51{
52 int : 0;
53};
54
55class Abstract
56{
57public:
58 virtual ~Abstract() = 0;
59};
60
61struct A
62{
63 A(const A&);
64};
65
66int main(int, char**)
67{
68 test_has_not_trivial_copy_constructor<void>();
69 test_has_not_trivial_copy_constructor<A>();
70 test_has_not_trivial_copy_constructor<Abstract>();
71 test_has_not_trivial_copy_constructor<NotEmpty>();
72
73 test_is_trivially_copy_constructible<int&>();
74 test_is_trivially_copy_constructible<Union>();
75 test_is_trivially_copy_constructible<Empty>();
76 test_is_trivially_copy_constructible<int>();
77 test_is_trivially_copy_constructible<double>();
78 test_is_trivially_copy_constructible<int*>();
79 test_is_trivially_copy_constructible<const int*>();
80 test_is_trivially_copy_constructible<bit_zero>();
81
82 return 0;
83}
84

source code of libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp