Index: include/type_traits =================================================================== --- include/type_traits +++ include/type_traits @@ -2911,6 +2911,9 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public __libcpp_trivial_destructor::type> {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]> + : public false_type {}; + #endif // is_nothrow_constructible @@ -3235,6 +3238,10 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __libcpp_nothrow_destructor::type> {}; +template +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]> + : public false_type {}; + #endif // is_pod Index: test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp =================================================================== --- test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp +++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp @@ -13,6 +13,8 @@ #include +#include "test_macros.h" + template void test_is_destructible() { @@ -68,6 +70,7 @@ struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; }; struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; }; +#if TEST_STD_VER >= 11 struct DeletedPublicDestructor { public: ~DeletedPublicDestructor() = delete; }; struct DeletedProtectedDestructor { protected: ~DeletedProtectedDestructor() = delete; }; struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor() = delete; }; @@ -75,6 +78,7 @@ struct DeletedVirtualPublicDestructor { public: virtual ~DeletedVirtualPublicDestructor() = delete; }; struct DeletedVirtualProtectedDestructor { protected: virtual ~DeletedVirtualProtectedDestructor() = delete; }; struct DeletedVirtualPrivateDestructor { private: virtual ~DeletedVirtualPrivateDestructor() = delete; }; +#endif int main() @@ -99,23 +103,27 @@ test_is_not_destructible(); test_is_not_destructible(); + test_is_not_destructible(); +#if TEST_STD_VER >= 11 + // Test access controlled destructors 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 deleted constructors 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(); // previously failed due to clang bug #20268 test_is_not_destructible(); test_is_not_destructible(); -#if __has_feature(cxx_access_control_sfinae) + // Test private destructors test_is_not_destructible(); #endif - test_is_not_destructible(); + } Index: test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp =================================================================== --- test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp +++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp @@ -13,6 +13,8 @@ #include +#include "test_macros.h" + template void test_is_nothrow_destructible() { @@ -31,14 +33,23 @@ static_assert(!std::is_nothrow_destructible::value, ""); } + +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 { }; -class NotEmpty -{ - virtual ~NotEmpty(); -}; union Union {}; @@ -52,40 +63,36 @@ virtual void foo() = 0; }; -class AbstractDestructor -{ - virtual ~AbstractDestructor() = 0; -}; - -struct A -{ - ~A(); -}; int main() { 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(); -#if __has_feature(cxx_noexcept) - test_is_nothrow_destructible(); -#endif test_is_nothrow_destructible(); -#if __has_feature(cxx_unrestricted_unions) - test_is_nothrow_destructible(); -#endif -#if __has_feature(cxx_access_control_sfinae) - test_is_nothrow_destructible(); -#endif 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 __has_feature(cxx_noexcept) + +#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 } Index: test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp =================================================================== --- test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp +++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp @@ -13,6 +13,8 @@ #include +#include "test_macros.h" + template void test_is_trivially_destructible() { @@ -31,13 +33,21 @@ static_assert(!std::is_trivially_destructible::value, ""); } -class Empty -{ -}; +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 NotEmpty + +class Empty { - virtual ~NotEmpty(); }; union Union {}; @@ -66,18 +76,28 @@ { test_is_not_trivially_destructible(); test_is_not_trivially_destructible(); - test_is_not_trivially_destructible(); - test_is_not_trivially_destructible(); test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); test_is_trivially_destructible(); - test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); + test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); + +#if TEST_STD_VER >= 11 + // requires access control sfinae + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); +#endif }