[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / utilities / meta / meta.unary / meta.unary.prop / is_empty.pass.cpp
blob850af8b7a75a00290243c2f3f30330c00802a171
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 //===----------------------------------------------------------------------===//
9 // type_traits
11 // is_empty
13 // T is a non-union class type with:
14 // no non-static data members,
15 // no unnamed bit-fields of non-zero length,
16 // no virtual member functions,
17 // no virtual base classes,
18 // and no base class B for which is_empty_v<B> is false.
21 #include <type_traits>
22 #include "test_macros.h"
24 template <class T>
25 void test_is_empty()
27 static_assert( std::is_empty<T>::value, "");
28 static_assert( std::is_empty<const T>::value, "");
29 static_assert( std::is_empty<volatile T>::value, "");
30 static_assert( std::is_empty<const volatile T>::value, "");
31 #if TEST_STD_VER > 14
32 static_assert( std::is_empty_v<T>, "");
33 static_assert( std::is_empty_v<const T>, "");
34 static_assert( std::is_empty_v<volatile T>, "");
35 static_assert( std::is_empty_v<const volatile T>, "");
36 #endif
39 template <class T>
40 void test_is_not_empty()
42 static_assert(!std::is_empty<T>::value, "");
43 static_assert(!std::is_empty<const T>::value, "");
44 static_assert(!std::is_empty<volatile T>::value, "");
45 static_assert(!std::is_empty<const volatile T>::value, "");
46 #if TEST_STD_VER > 14
47 static_assert(!std::is_empty_v<T>, "");
48 static_assert(!std::is_empty_v<const T>, "");
49 static_assert(!std::is_empty_v<volatile T>, "");
50 static_assert(!std::is_empty_v<const volatile T>, "");
51 #endif
54 class Empty {};
55 struct NotEmpty { int foo; };
57 class VirtualFn
59 virtual ~VirtualFn();
62 union Union {};
64 struct EmptyBase : public Empty {};
65 struct VirtualBase : virtual Empty {};
66 struct NotEmptyBase : public NotEmpty {};
68 struct StaticMember { static int foo; };
69 struct NonStaticMember { int foo; };
71 struct bit_zero
73 int : 0;
76 struct bit_one
78 int : 1;
81 int main(int, char**)
83 test_is_not_empty<void>();
84 test_is_not_empty<int&>();
85 test_is_not_empty<int>();
86 test_is_not_empty<double>();
87 test_is_not_empty<int*>();
88 test_is_not_empty<const int*>();
89 test_is_not_empty<char[3]>();
90 test_is_not_empty<char[]>();
91 test_is_not_empty<Union>();
92 test_is_not_empty<NotEmpty>();
93 test_is_not_empty<VirtualFn>();
94 test_is_not_empty<VirtualBase>();
95 test_is_not_empty<NotEmptyBase>();
96 test_is_not_empty<NonStaticMember>();
97 // test_is_not_empty<bit_one>();
99 test_is_empty<Empty>();
100 test_is_empty<EmptyBase>();
101 test_is_empty<StaticMember>();
102 test_is_empty<bit_zero>();
104 return 0;