1 | |
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). |
6 | // |
7 | // See http://www.boost.org/libs/type_traits for most recent version including documentation. |
8 | |
9 | #ifndef BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED |
10 | #define BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED |
11 | |
12 | #include <boost/type_traits/intrinsics.hpp> |
13 | #include <boost/type_traits/integral_constant.hpp> |
14 | |
15 | #ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR |
16 | |
17 | #if defined(BOOST_MSVC) || defined(BOOST_INTEL) |
18 | #include <boost/type_traits/has_trivial_constructor.hpp> |
19 | #endif |
20 | #if defined(__GNUC__ ) || defined(__SUNPRO_CC) |
21 | #include <boost/type_traits/is_default_constructible.hpp> |
22 | #endif |
23 | |
24 | namespace boost { |
25 | |
26 | template <class T> struct has_nothrow_constructor : public integral_constant<bool, BOOST_HAS_NOTHROW_CONSTRUCTOR(T)>{}; |
27 | |
28 | #elif !defined(BOOST_NO_CXX11_NOEXCEPT) |
29 | |
30 | #include <boost/type_traits/is_default_constructible.hpp> |
31 | #include <boost/type_traits/remove_all_extents.hpp> |
32 | |
33 | #ifdef BOOST_MSVC |
34 | #pragma warning(push) |
35 | #pragma warning(disable:4197) // top-level volatile in cast is ignored |
36 | #endif |
37 | |
38 | namespace boost { namespace detail{ |
39 | |
40 | template <class T, bool b> struct has_nothrow_constructor_imp : public boost::integral_constant<bool, false>{}; |
41 | template <class T> struct has_nothrow_constructor_imp<T, true> : public boost::integral_constant<bool, noexcept(T())>{}; |
42 | template <class T, std::size_t N> struct has_nothrow_constructor_imp<T[N], true> : public has_nothrow_constructor_imp<T, true> {}; |
43 | } |
44 | |
45 | template <class T> struct has_nothrow_constructor : public detail::has_nothrow_constructor_imp<T, is_default_constructible<T>::value>{}; |
46 | |
47 | #ifdef BOOST_MSVC |
48 | #pragma warning(pop) |
49 | #endif |
50 | |
51 | #else |
52 | |
53 | #include <boost/type_traits/has_trivial_constructor.hpp> |
54 | |
55 | namespace boost { |
56 | |
57 | template <class T> struct has_nothrow_constructor : public ::boost::has_trivial_constructor<T> {}; |
58 | |
59 | #endif |
60 | |
61 | template<> struct has_nothrow_constructor<void> : public false_type {}; |
62 | #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS |
63 | template<> struct has_nothrow_constructor<void const> : public false_type{}; |
64 | template<> struct has_nothrow_constructor<void const volatile> : public false_type{}; |
65 | template<> struct has_nothrow_constructor<void volatile> : public false_type{}; |
66 | #endif |
67 | |
68 | template <class T> struct has_nothrow_default_constructor : public has_nothrow_constructor<T>{}; |
69 | |
70 | } // namespace boost |
71 | |
72 | #endif // BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED |
73 | |