summaryrefslogtreecommitdiff
path: root/boost/type_traits/has_nothrow_constructor.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/type_traits/has_nothrow_constructor.hpp')
-rw-r--r--boost/type_traits/has_nothrow_constructor.hpp67
1 files changed, 43 insertions, 24 deletions
diff --git a/boost/type_traits/has_nothrow_constructor.hpp b/boost/type_traits/has_nothrow_constructor.hpp
index 3bc4f802c2..e5af89fe59 100644
--- a/boost/type_traits/has_nothrow_constructor.hpp
+++ b/boost/type_traits/has_nothrow_constructor.hpp
@@ -9,45 +9,64 @@
#ifndef BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED
#define BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED
-#include <boost/type_traits/has_trivial_constructor.hpp>
+#include <boost/type_traits/intrinsics.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+
+#ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR
-// should be the last #include
-#include <boost/type_traits/detail/bool_trait_def.hpp>
+#if defined(BOOST_MSVC) || defined(BOOST_INTEL)
+#include <boost/type_traits/has_trivial_constructor.hpp>
+#endif
+#if defined(__GNUC__ ) || defined(__SUNPRO_CC)
+#include <boost/type_traits/is_default_constructible.hpp>
+#endif
namespace boost {
-namespace detail{
+template <class T> struct has_nothrow_constructor : public integral_constant<bool, BOOST_HAS_NOTHROW_CONSTRUCTOR(T)>{};
-template <class T>
-struct has_nothrow_constructor_imp{
-#ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR
- BOOST_STATIC_CONSTANT(bool, value = BOOST_HAS_NOTHROW_CONSTRUCTOR(T));
-#else
- BOOST_STATIC_CONSTANT(bool, value = ::boost::has_trivial_constructor<T>::value);
+#elif !defined(BOOST_NO_CXX11_NOEXCEPT)
+
+#include <boost/type_traits/is_default_constructible.hpp>
+#include <boost/type_traits/remove_all_extents.hpp>
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4197) // top-level volatile in cast is ignored
#endif
-};
+namespace boost { namespace detail{
+
+ template <class T, bool b> struct has_nothrow_constructor_imp : public boost::integral_constant<bool, false>{};
+ template <class T> struct has_nothrow_constructor_imp<T, true> : public boost::integral_constant<bool, noexcept(T())>{};
+ template <class T, std::size_t N> struct has_nothrow_constructor_imp<T[N], true> : public has_nothrow_constructor_imp<T, true> {};
}
-BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_nothrow_constructor,T,::boost::detail::has_nothrow_constructor_imp<T>::value)
-BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_nothrow_default_constructor,T,::boost::detail::has_nothrow_constructor_imp<T>::value)
+template <class T> struct has_nothrow_constructor : public detail::has_nothrow_constructor_imp<T, is_default_constructible<T>::value>{};
-BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_constructor,void,false)
-#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
-BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_constructor,void const,false)
-BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_constructor,void const volatile,false)
-BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_constructor,void volatile,false)
+#ifdef BOOST_MSVC
+#pragma warning(pop)
#endif
-BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_default_constructor,void,false)
+#else
+
+#include <boost/type_traits/has_trivial_constructor.hpp>
+
+namespace boost {
+
+template <class T> struct has_nothrow_constructor : public ::boost::has_trivial_constructor<T> {};
+
+#endif
+
+template<> struct has_nothrow_constructor<void> : public false_type {};
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
-BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_default_constructor,void const,false)
-BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_default_constructor,void const volatile,false)
-BOOST_TT_AUX_BOOL_TRAIT_SPEC1(has_nothrow_default_constructor,void volatile,false)
+template<> struct has_nothrow_constructor<void const> : public false_type{};
+template<> struct has_nothrow_constructor<void const volatile> : public false_type{};
+template<> struct has_nothrow_constructor<void volatile> : public false_type{};
#endif
-} // namespace boost
+template <class T> struct has_nothrow_default_constructor : public has_nothrow_constructor<T>{};
-#include <boost/type_traits/detail/bool_trait_undef.hpp>
+} // namespace boost
#endif // BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED