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_rvalue_reference
13
14 // UNSUPPORTED: c++98, c++03
15
16 #include <type_traits>
17 #include <cstddef> // for std::nullptr_t
18 #include "test_macros.h"
19
20 template <class T>
test_is_rvalue_reference()21 void test_is_rvalue_reference()
22 {
23 static_assert( std::is_rvalue_reference<T>::value, "");
24 static_assert( std::is_rvalue_reference<const T>::value, "");
25 static_assert( std::is_rvalue_reference<volatile T>::value, "");
26 static_assert( std::is_rvalue_reference<const volatile T>::value, "");
27 #if TEST_STD_VER > 14
28 static_assert( std::is_rvalue_reference_v<T>, "");
29 static_assert( std::is_rvalue_reference_v<const T>, "");
30 static_assert( std::is_rvalue_reference_v<volatile T>, "");
31 static_assert( std::is_rvalue_reference_v<const volatile T>, "");
32 #endif
33 }
34
35 template <class T>
test_is_not_rvalue_reference()36 void test_is_not_rvalue_reference()
37 {
38 static_assert(!std::is_rvalue_reference<T>::value, "");
39 static_assert(!std::is_rvalue_reference<const T>::value, "");
40 static_assert(!std::is_rvalue_reference<volatile T>::value, "");
41 static_assert(!std::is_rvalue_reference<const volatile T>::value, "");
42 #if TEST_STD_VER > 14
43 static_assert(!std::is_rvalue_reference_v<T>, "");
44 static_assert(!std::is_rvalue_reference_v<const T>, "");
45 static_assert(!std::is_rvalue_reference_v<volatile T>, "");
46 static_assert(!std::is_rvalue_reference_v<const volatile T>, "");
47 #endif
48 }
49
50 class Empty
51 {
52 };
53
54 class NotEmpty
55 {
56 virtual ~NotEmpty();
57 };
58
59 union Union {};
60
61 struct bit_zero
62 {
63 int : 0;
64 };
65
66 class Abstract
67 {
68 virtual ~Abstract() = 0;
69 };
70
71 enum Enum {zero, one};
72 struct incomplete_type;
73
74 typedef void (*FunctionPtr)();
75
main()76 int main()
77 {
78 test_is_rvalue_reference<int&&>();
79
80 test_is_not_rvalue_reference<std::nullptr_t>();
81 test_is_not_rvalue_reference<void>();
82 test_is_not_rvalue_reference<int>();
83 test_is_not_rvalue_reference<int*>();
84 test_is_not_rvalue_reference<int&>();
85 test_is_not_rvalue_reference<double>();
86 test_is_not_rvalue_reference<const int*>();
87 test_is_not_rvalue_reference<char[3]>();
88 test_is_not_rvalue_reference<char[]>();
89 test_is_not_rvalue_reference<Union>();
90 test_is_not_rvalue_reference<Enum>();
91 test_is_not_rvalue_reference<FunctionPtr>();
92 test_is_not_rvalue_reference<Empty>();
93 test_is_not_rvalue_reference<bit_zero>();
94 test_is_not_rvalue_reference<NotEmpty>();
95 test_is_not_rvalue_reference<Abstract>();
96 test_is_not_rvalue_reference<incomplete_type>();
97 }
98