]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 <cstddef> // size_t | |
13 | #include <boost/type_traits/intrinsics.hpp> | |
14 | #include <boost/type_traits/integral_constant.hpp> | |
15 | ||
16 | #ifdef BOOST_HAS_NOTHROW_CONSTRUCTOR | |
17 | ||
18 | #if defined(BOOST_MSVC) || defined(BOOST_INTEL) | |
19 | #include <boost/type_traits/has_trivial_constructor.hpp> | |
20 | #endif | |
21 | #if defined(__GNUC__ ) || defined(__SUNPRO_CC) || defined(__clang__) | |
22 | #include <boost/type_traits/is_default_constructible.hpp> | |
23 | #endif | |
24 | ||
25 | namespace boost { | |
26 | ||
27 | template <class T> struct has_nothrow_constructor : public integral_constant<bool, BOOST_HAS_NOTHROW_CONSTRUCTOR(T)>{}; | |
28 | ||
29 | #elif !defined(BOOST_NO_CXX11_NOEXCEPT) | |
30 | ||
31 | #include <boost/type_traits/is_default_constructible.hpp> | |
32 | #include <boost/type_traits/remove_all_extents.hpp> | |
33 | ||
34 | #ifdef BOOST_MSVC | |
35 | #pragma warning(push) | |
36 | #pragma warning(disable:4197) // top-level volatile in cast is ignored | |
37 | #endif | |
38 | ||
39 | namespace boost { namespace detail{ | |
40 | ||
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> {}; | |
44 | } | |
45 | ||
46 | template <class T> struct has_nothrow_constructor : public detail::has_nothrow_constructor_imp<T, is_default_constructible<T>::value>{}; | |
47 | ||
48 | #ifdef BOOST_MSVC | |
49 | #pragma warning(pop) | |
50 | #endif | |
51 | ||
52 | #else | |
53 | ||
54 | #include <boost/type_traits/has_trivial_constructor.hpp> | |
55 | ||
56 | namespace boost { | |
57 | ||
58 | template <class T> struct has_nothrow_constructor : public ::boost::has_trivial_constructor<T> {}; | |
59 | ||
60 | #endif | |
61 | ||
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{}; | |
67 | #endif | |
68 | ||
69 | template <class T> struct has_nothrow_default_constructor : public has_nothrow_constructor<T>{}; | |
70 | ||
71 | } // namespace boost | |
72 | ||
73 | #endif // BOOST_TT_HAS_NOTHROW_CONSTRUCTOR_HPP_INCLUDED |