1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
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"
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
, "");
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
>, "");
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
, "");
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
>, "");
55 struct NotEmpty
{ int foo
; };
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
; };
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
>();