Improve is_destructible - especially for references.

This commit is contained in:
jzmaddock
2015-06-11 10:13:30 +01:00
parent 434e26e7a3
commit 11cd9e6674
2 changed files with 19 additions and 2 deletions

View File

@ -32,8 +32,6 @@ namespace boost{
}
template <class T> struct is_destructible : public integral_constant<bool, sizeof(detail::is_destructible_imp::test<T>(0)) == sizeof(boost::type_traits::yes_type)>{};
template <class T, std::size_t N> struct is_destructible<T[N]> : public is_destructible<T>{};
template <class T> struct is_destructible<T[]> : public is_destructible<T>{};
#else
@ -50,6 +48,12 @@ namespace boost{
template <> struct is_destructible<void const> : public false_type{};
template <> struct is_destructible<void volatile> : public false_type{};
template <> struct is_destructible<void const volatile> : public false_type{};
template <class T> struct is_destructible<T&> : public is_destructible<T>{};
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
template <class T> struct is_destructible<T&&> : public is_destructible<T>{};
#endif
template <class T, std::size_t N> struct is_destructible<T[N]> : public is_destructible<T>{};
template <class T> struct is_destructible<T[]> : public is_destructible<T>{};
} // namespace boost

View File

@ -151,6 +151,19 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<mf3>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<mp>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<cmf>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT&>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT const>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT const volatile>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT volatile>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT const&>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT const volatile&>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT volatile&>::value, true);
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT&&>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT const&&>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT const volatile&&>::value, true);
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_destructible<enum_UDT volatile&&>::value, true);
#endif
//
// These are commented out for now because it's not clear what the semantics should be: