//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // type_traits // is_empty // T is a non-union class type with: // no non-static data members, // no unnamed bit-fields of non-zero length, // no virtual member functions, // no virtual base classes, // and no base class B for which is_empty_v is false. #include #include "test_macros.h" template void test_is_empty() { static_assert( std::is_empty::value, ""); static_assert( std::is_empty::value, ""); static_assert( std::is_empty::value, ""); static_assert( std::is_empty::value, ""); #if TEST_STD_VER > 14 static_assert( std::is_empty_v, ""); static_assert( std::is_empty_v, ""); static_assert( std::is_empty_v, ""); static_assert( std::is_empty_v, ""); #endif } template void test_is_not_empty() { static_assert(!std::is_empty::value, ""); static_assert(!std::is_empty::value, ""); static_assert(!std::is_empty::value, ""); static_assert(!std::is_empty::value, ""); #if TEST_STD_VER > 14 static_assert(!std::is_empty_v, ""); static_assert(!std::is_empty_v, ""); static_assert(!std::is_empty_v, ""); static_assert(!std::is_empty_v, ""); #endif } class Empty {}; struct NotEmpty { int foo; }; class VirtualFn { virtual ~VirtualFn(); }; union Union {}; struct EmptyBase : public Empty {}; struct VirtualBase : virtual Empty {}; struct NotEmptyBase : public NotEmpty {}; struct StaticMember { static int foo; }; struct NonStaticMember { int foo; }; struct bit_zero { int : 0; }; struct bit_one { int : 1; }; int main(int, char**) { test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); test_is_not_empty(); // test_is_not_empty(); test_is_empty(); test_is_empty(); test_is_empty(); test_is_empty(); return 0; }