blob: 89639377ce81a564785949f47dfb16e9d7b8472d [file] [log] [blame]
Marshall Clow94611a82015-11-01 20:24:59 +00001//===----------------------------------------------------------------------===//
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>
Marshall Clow55d741c2015-11-10 15:48:23 +000017#include <cstddef> // for std::nullptr_t
Marshall Clow94611a82015-11-01 20:24:59 +000018#include "test_macros.h"
19
20template <class T>
21void 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
35template <class T>
36void 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
50class Empty
51{
52};
53
54class NotEmpty
55{
56 virtual ~NotEmpty();
57};
58
59union Union {};
60
61struct bit_zero
62{
63 int : 0;
64};
65
66class Abstract
67{
68 virtual ~Abstract() = 0;
69};
70
71enum Enum {zero, one};
Marshall Clow7490f532016-02-25 20:15:47 +000072struct incomplete_type;
Marshall Clow94611a82015-11-01 20:24:59 +000073
74typedef void (*FunctionPtr)();
75
76int 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>();
Marshall Clow7490f532016-02-25 20:15:47 +000096 test_is_not_rvalue_reference<incomplete_type>();
Marshall Clow94611a82015-11-01 20:24:59 +000097}