Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / meta / meta.unary / meta.unary.prop / is_trivially_copy_constructible.pass.cpp
blob09647c7107e18653294c57075093aa96ec02e967
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 //===----------------------------------------------------------------------===//
9 // type_traits
11 // is_trivially_copy_constructible
13 #include <type_traits>
14 #include "test_macros.h"
16 template <class T>
17 void test_is_trivially_copy_constructible()
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
27 template <class T>
28 void test_has_not_trivial_copy_constructor()
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
38 class Empty
42 class NotEmpty
44 public:
45 virtual ~NotEmpty();
48 union Union {};
50 struct bit_zero
52 int : 0;
55 class Abstract
57 public:
58 virtual ~Abstract() = 0;
61 struct A
63 A(const A&);
66 int main(int, char**)
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>();
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>();
82 return 0;