Correctly implement LWG 2049; std::is_destructible.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@213163 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -24,6 +24,16 @@ private:
|
||||
A(char);
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual void foo() = 0;
|
||||
};
|
||||
|
||||
class AbstractDestructor
|
||||
{
|
||||
virtual ~AbstractDestructor() = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void test_is_constructible()
|
||||
{
|
||||
@@ -71,4 +81,6 @@ int main()
|
||||
test_is_not_constructible<A, void> ();
|
||||
test_is_not_constructible<void> ();
|
||||
test_is_not_constructible<int&> ();
|
||||
test_is_not_constructible<Abstract> ();
|
||||
test_is_not_constructible<AbstractDestructor> ();
|
||||
}
|
||||
|
@@ -31,9 +31,7 @@ void test_is_not_destructible()
|
||||
static_assert(!std::is_destructible<const volatile T>::value, "");
|
||||
}
|
||||
|
||||
class Empty
|
||||
{
|
||||
};
|
||||
class Empty {};
|
||||
|
||||
class NotEmpty
|
||||
{
|
||||
@@ -47,11 +45,6 @@ struct bit_zero
|
||||
int : 0;
|
||||
};
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
};
|
||||
|
||||
struct A
|
||||
{
|
||||
~A();
|
||||
@@ -59,6 +52,31 @@ struct 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<A>();
|
||||
@@ -72,10 +90,30 @@ int main()
|
||||
test_is_destructible<char[3]>();
|
||||
test_is_destructible<bit_zero>();
|
||||
test_is_destructible<int[3]>();
|
||||
test_is_destructible<ProtectedAbstract>();
|
||||
test_is_destructible<PublicAbstract>();
|
||||
test_is_destructible<PrivateAbstract>();
|
||||
test_is_destructible<PublicDestructor>();
|
||||
test_is_destructible<VirtualPublicDestructor>();
|
||||
test_is_destructible<PurePublicDestructor>();
|
||||
|
||||
test_is_not_destructible<int[]>();
|
||||
test_is_not_destructible<void>();
|
||||
test_is_not_destructible<Abstract>();
|
||||
|
||||
test_is_not_destructible<ProtectedDestructor>();
|
||||
test_is_not_destructible<PrivateDestructor>();
|
||||
test_is_not_destructible<VirtualProtectedDestructor>();
|
||||
test_is_not_destructible<VirtualPrivateDestructor>();
|
||||
test_is_not_destructible<PureProtectedDestructor>();
|
||||
test_is_not_destructible<PurePrivateDestructor>();
|
||||
test_is_not_destructible<DeletedPublicDestructor>();
|
||||
test_is_not_destructible<DeletedProtectedDestructor>();
|
||||
test_is_not_destructible<DeletedPrivateDestructor>();
|
||||
|
||||
// test_is_not_destructible<DeletedVirtualPublicDestructor>(); // currently fails due to clang bug #20268
|
||||
test_is_not_destructible<DeletedVirtualProtectedDestructor>();
|
||||
test_is_not_destructible<DeletedVirtualPrivateDestructor>();
|
||||
|
||||
#if __has_feature(cxx_access_control_sfinae)
|
||||
test_is_not_destructible<NotEmpty>();
|
||||
#endif
|
||||
|
@@ -49,7 +49,12 @@ struct bit_zero
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
virtual void foo() = 0;
|
||||
};
|
||||
|
||||
class AbstractDestructor
|
||||
{
|
||||
virtual ~AbstractDestructor() = 0;
|
||||
};
|
||||
|
||||
struct A
|
||||
@@ -60,7 +65,7 @@ struct A
|
||||
int main()
|
||||
{
|
||||
test_has_not_nothrow_destructor<void>();
|
||||
test_has_not_nothrow_destructor<Abstract>();
|
||||
test_has_not_nothrow_destructor<AbstractDestructor>();
|
||||
test_has_not_nothrow_destructor<NotEmpty>();
|
||||
|
||||
#if __has_feature(cxx_noexcept)
|
||||
@@ -79,6 +84,7 @@ int main()
|
||||
test_is_nothrow_destructible<const int*>();
|
||||
test_is_nothrow_destructible<char[3]>();
|
||||
test_is_nothrow_destructible<char[3]>();
|
||||
test_is_nothrow_destructible<Abstract>();
|
||||
#if __has_feature(cxx_noexcept)
|
||||
test_is_nothrow_destructible<bit_zero>();
|
||||
#endif
|
||||
|
@@ -49,7 +49,12 @@ struct bit_zero
|
||||
|
||||
class Abstract
|
||||
{
|
||||
virtual ~Abstract() = 0;
|
||||
virtual void foo() = 0;
|
||||
};
|
||||
|
||||
class AbstractDestructor
|
||||
{
|
||||
virtual ~AbstractDestructor() = 0;
|
||||
};
|
||||
|
||||
struct A
|
||||
@@ -61,9 +66,10 @@ int main()
|
||||
{
|
||||
test_has_not_trivial_destructor<void>();
|
||||
test_has_not_trivial_destructor<A>();
|
||||
test_has_not_trivial_destructor<Abstract>();
|
||||
test_has_not_trivial_destructor<AbstractDestructor>();
|
||||
test_has_not_trivial_destructor<NotEmpty>();
|
||||
|
||||
test_is_trivially_destructible<Abstract>();
|
||||
test_is_trivially_destructible<int&>();
|
||||
test_is_trivially_destructible<Union>();
|
||||
test_is_trivially_destructible<Empty>();
|
||||
|
Reference in New Issue
Block a user