1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // is_trivially_copyable
13 #include <type_traits>
15 #include "test_macros.h"
18 void test_is_trivially_copyable()
20 static_assert( std::is_trivially_copyable
<T
>::value
, "");
21 static_assert( std::is_trivially_copyable
<const T
>::value
, "");
22 static_assert( std::is_trivially_copyable
<volatile T
>::value
, "");
23 static_assert( std::is_trivially_copyable
<const volatile T
>::value
, "");
25 static_assert( std::is_trivially_copyable_v
<T
>, "");
26 static_assert( std::is_trivially_copyable_v
<const T
>, "");
27 static_assert( std::is_trivially_copyable_v
<volatile T
>, "");
28 static_assert( std::is_trivially_copyable_v
<const volatile T
>, "");
33 void test_is_not_trivially_copyable()
35 static_assert(!std::is_trivially_copyable
<T
>::value
, "");
36 static_assert(!std::is_trivially_copyable
<const T
>::value
, "");
37 static_assert(!std::is_trivially_copyable
<volatile T
>::value
, "");
38 static_assert(!std::is_trivially_copyable
<const volatile T
>::value
, "");
40 static_assert(!std::is_trivially_copyable_v
<T
>, "");
41 static_assert(!std::is_trivially_copyable_v
<const T
>, "");
42 static_assert(!std::is_trivially_copyable_v
<volatile T
>, "");
43 static_assert(!std::is_trivially_copyable_v
<const volatile T
>, "");
55 ~B() {assert(i_
== 0);}
66 test_is_trivially_copyable
<int> ();
67 test_is_trivially_copyable
<const int> ();
68 test_is_trivially_copyable
<A
> ();
69 test_is_trivially_copyable
<const A
> ();
70 test_is_trivially_copyable
<C
> ();
72 test_is_not_trivially_copyable
<int&> ();
73 test_is_not_trivially_copyable
<const A
&> ();
74 test_is_not_trivially_copyable
<B
> ();