//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // type_traits // is_nothrow_destructible // Prevent warning when testing the Abstract test type. #if defined(__clang__) #pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor" #endif #include #include "test_macros.h" template void test_is_nothrow_destructible() { static_assert( std::is_nothrow_destructible::value, ""); static_assert( std::is_nothrow_destructible::value, ""); static_assert( std::is_nothrow_destructible::value, ""); static_assert( std::is_nothrow_destructible::value, ""); #if TEST_STD_VER > 14 static_assert( std::is_nothrow_destructible_v, ""); static_assert( std::is_nothrow_destructible_v, ""); static_assert( std::is_nothrow_destructible_v, ""); static_assert( std::is_nothrow_destructible_v, ""); #endif } template void test_is_not_nothrow_destructible() { static_assert(!std::is_nothrow_destructible::value, ""); static_assert(!std::is_nothrow_destructible::value, ""); static_assert(!std::is_nothrow_destructible::value, ""); static_assert(!std::is_nothrow_destructible::value, ""); #if TEST_STD_VER > 14 static_assert(!std::is_nothrow_destructible_v, ""); static_assert(!std::is_nothrow_destructible_v, ""); static_assert(!std::is_nothrow_destructible_v, ""); static_assert(!std::is_nothrow_destructible_v, ""); #endif } struct PublicDestructor { public: ~PublicDestructor() {}}; struct ProtectedDestructor { protected: ~ProtectedDestructor() {}}; struct PrivateDestructor { private: ~PrivateDestructor() {}}; struct VirtualPublicDestructor { public: virtual ~VirtualPublicDestructor() {}}; struct VirtualProtectedDestructor { protected: virtual ~VirtualProtectedDestructor() {}}; struct VirtualPrivateDestructor { private: virtual ~VirtualPrivateDestructor() {}}; struct PurePublicDestructor { public: virtual ~PurePublicDestructor() = 0; }; struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; }; struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; }; class Empty { }; union Union {}; struct bit_zero { int : 0; }; class Abstract { virtual void foo() = 0; }; int main() { test_is_not_nothrow_destructible(); test_is_not_nothrow_destructible(); test_is_not_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); #if TEST_STD_VER >= 11 // requires noexcept. These are all destructible. test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); // requires access control test_is_not_nothrow_destructible(); test_is_not_nothrow_destructible(); test_is_not_nothrow_destructible(); test_is_not_nothrow_destructible(); test_is_not_nothrow_destructible(); test_is_not_nothrow_destructible(); #endif }