• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // type_traits
11 
12 // is_trivially_assignable
13 
14 // XFAIL: gcc-4.9
15 
16 #include <type_traits>
17 #include "test_macros.h"
18 
19 template <class T, class U>
test_is_trivially_assignable()20 void test_is_trivially_assignable()
21 {
22     static_assert(( std::is_trivially_assignable<T, U>::value), "");
23 #if TEST_STD_VER > 14
24     static_assert(( std::is_trivially_assignable_v<T, U>), "");
25 #endif
26 }
27 
28 template <class T, class U>
test_is_not_trivially_assignable()29 void test_is_not_trivially_assignable()
30 {
31     static_assert((!std::is_trivially_assignable<T, U>::value), "");
32 #if TEST_STD_VER > 14
33     static_assert((!std::is_trivially_assignable_v<T, U>), "");
34 #endif
35 }
36 
37 struct A
38 {
39 };
40 
41 struct B
42 {
43     void operator=(A);
44 };
45 
46 struct C
47 {
48     void operator=(C&);  // not const
49 };
50 
main()51 int main()
52 {
53     test_is_trivially_assignable<int&, int&> ();
54     test_is_trivially_assignable<int&, int> ();
55     test_is_trivially_assignable<int&, double> ();
56 
57     test_is_not_trivially_assignable<int, int&> ();
58     test_is_not_trivially_assignable<int, int> ();
59     test_is_not_trivially_assignable<B, A> ();
60     test_is_not_trivially_assignable<A, B> ();
61     test_is_not_trivially_assignable<C&, C&> ();
62 }
63