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_assignable
12
13#include <type_traits>
14#include "test_macros.h"
15
16template <class T, class U>
17void test_is_trivially_assignable()
18{
19 static_assert(( std::is_trivially_assignable<T, U>::value), "");
20#if TEST_STD_VER > 14
21 static_assert(( std::is_trivially_assignable_v<T, U>), "");
22#endif
23}
24
25template <class T, class U>
26void test_is_not_trivially_assignable()
27{
28 static_assert((!std::is_trivially_assignable<T, U>::value), "");
29#if TEST_STD_VER > 14
30 static_assert((!std::is_trivially_assignable_v<T, U>), "");
31#endif
32}
33
34struct A
35{
36};
37
38struct B
39{
40 void operator=(A);
41};
42
43struct C
44{
45 void operator=(C&); // not const
46};
47
48int main(int, char**)
49{
50 test_is_trivially_assignable<int&, int&> ();
51 test_is_trivially_assignable<int&, int> ();
52 test_is_trivially_assignable<int&, double> ();
53
54 test_is_not_trivially_assignable<int, int&> ();
55 test_is_not_trivially_assignable<int, int> ();
56 test_is_not_trivially_assignable<B, A> ();
57 test_is_not_trivially_assignable<A, B> ();
58 test_is_not_trivially_assignable<C&, C&> ();
59
60 return 0;
61}
62

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