has_nothrow_destructor.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. //
  6. // See http://www.boost.org/libs/type_traits for most recent version including documentation.
  7. #ifndef BOOST_TT_HAS_NOTHROW_DESTRUCTOR_HPP_INCLUDED
  8. #define BOOST_TT_HAS_NOTHROW_DESTRUCTOR_HPP_INCLUDED
  9. #include <boost/type_traits/has_trivial_destructor.hpp>
  10. #if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(__SUNPRO_CC) && !(defined(BOOST_MSVC) && (_MSC_FULL_VER < 190023506))
  11. #include <boost/type_traits/declval.hpp>
  12. #include <boost/type_traits/is_destructible.hpp>
  13. #include <boost/type_traits/is_complete.hpp>
  14. #include <boost/static_assert.hpp>
  15. namespace boost{
  16. namespace detail{
  17. template <class T, bool b>
  18. struct has_nothrow_destructor_imp : public boost::integral_constant<bool, false>{};
  19. template <class T>
  20. struct has_nothrow_destructor_imp<T, true> : public boost::integral_constant<bool, noexcept(boost::declval<T*&>()->~T())>{};
  21. }
  22. template <class T> struct has_nothrow_destructor : public detail::has_nothrow_destructor_imp<T, boost::is_destructible<T>::value>
  23. {
  24. BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to has_nothrow_destructor must be complete types");
  25. };
  26. template <class T, std::size_t N> struct has_nothrow_destructor<T[N]> : public has_nothrow_destructor<T>
  27. {
  28. BOOST_STATIC_ASSERT_MSG(boost::is_complete<T>::value, "Arguments to has_nothrow_destructor must be complete types");
  29. };
  30. template <class T> struct has_nothrow_destructor<T&> : public integral_constant<bool, false>{};
  31. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  32. template <class T> struct has_nothrow_destructor<T&&> : public integral_constant<bool, false>{};
  33. #endif
  34. template <> struct has_nothrow_destructor<void> : public false_type {};
  35. }
  36. #else
  37. namespace boost {
  38. template <class T> struct has_nothrow_destructor : public ::boost::has_trivial_destructor<T> {};
  39. } // namespace boost
  40. #endif
  41. #endif // BOOST_TT_HAS_NOTHROW_DESTRUCTOR_HPP_INCLUDED