//===----------------------------------------------------------------------===// // // 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_destructible #include template void test_is_destructible() { static_assert( std::is_destructible::value, ""); static_assert( std::is_destructible::value, ""); static_assert( std::is_destructible::value, ""); static_assert( std::is_destructible::value, ""); } template void test_is_not_destructible() { static_assert(!std::is_destructible::value, ""); static_assert(!std::is_destructible::value, ""); static_assert(!std::is_destructible::value, ""); static_assert(!std::is_destructible::value, ""); } class Empty {}; class NotEmpty { virtual ~NotEmpty(); }; union Union {}; struct bit_zero { int : 0; }; struct A { ~A(); }; typedef void (Function) (); struct PublicAbstract { public: virtual void foo() = 0; }; struct ProtectedAbstract { protected: virtual void foo() = 0; }; struct PrivateAbstract { private: virtual void foo() = 0; }; 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; }; struct DeletedPublicDestructor { public: ~DeletedPublicDestructor() = delete; }; struct DeletedProtectedDestructor { protected: ~DeletedProtectedDestructor() = delete; }; struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor() = delete; }; struct DeletedVirtualPublicDestructor { public: virtual ~DeletedVirtualPublicDestructor() = delete; }; struct DeletedVirtualProtectedDestructor { protected: virtual ~DeletedVirtualProtectedDestructor() = delete; }; struct DeletedVirtualPrivateDestructor { private: virtual ~DeletedVirtualPrivateDestructor() = delete; }; int main() { test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); // test_is_not_destructible(); // currently fails due to clang bug #20268 test_is_not_destructible(); test_is_not_destructible(); #if __has_feature(cxx_access_control_sfinae) test_is_not_destructible(); #endif test_is_not_destructible(); }