2 // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt).
7 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
9 #ifndef BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED
10 #define BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED
12 #include <cstddef> // size_t
13 #include <boost/type_traits/intrinsics.hpp>
14 #include <boost/type_traits/integral_constant.hpp>
16 #ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR
18 #if defined(BOOST_MSVC) || defined(BOOST_INTEL)
19 #include <boost/type_traits/has_trivial_constructor.hpp>
21 #if defined(__GNUC__ ) || defined(__SUNPRO_CC) || defined(__clang__)
22 #include <boost/type_traits/is_default_constructible.hpp>
27 template <class T> struct has_nothrow_constructor : public integral_constant<bool, BOOST_HAS_NOTHROW_CONSTRUCTOR(T)>{};
29 #elif !defined(BOOST_NO_CXX11_NOEXCEPT)
31 #include <boost/type_traits/is_default_constructible.hpp>
32 #include <boost/type_traits/remove_all_extents.hpp>
36 #pragma warning(disable:4197) // top-level volatile in cast is ignored
39 namespace boost { namespace detail{
41 template <class T, bool b> struct has_nothrow_constructor_imp : public boost::integral_constant<bool, false>{};
42 template <class T> struct has_nothrow_constructor_imp<T, true> : public boost::integral_constant<bool, noexcept(T())>{};
43 template <class T, std::size_t N> struct has_nothrow_constructor_imp<T[N], true> : public has_nothrow_constructor_imp<T, true> {};
46 template <class T> struct has_nothrow_constructor : public detail::has_nothrow_constructor_imp<T, is_default_constructible<T>::value>{};
54 #include <boost/type_traits/has_trivial_constructor.hpp>
58 template <class T> struct has_nothrow_constructor : public ::boost::has_trivial_constructor<T> {};
62 template<> struct has_nothrow_constructor<void> : public false_type {};
63 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
64 template<> struct has_nothrow_constructor<void const> : public false_type{};
65 template<> struct has_nothrow_constructor<void const volatile> : public false_type{};
66 template<> struct has_nothrow_constructor<void volatile> : public false_type{};
69 template <class T> struct has_nothrow_default_constructor : public has_nothrow_constructor<T>{};
73 #endif // BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED