2 // (C) Copyright Runar Undheim, Robert Ramey & John Maddock 2008.
\r
3 // Use, modification and distribution are subject to the Boost Software License,
\r
4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
\r
5 // http://www.boost.org/LICENSE_1_0.txt).
\r
7 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
\r
9 #ifndef BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
\r
10 #define BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
\r
12 #include <new> // std::nothrow_t
\r
13 #include <cstddef> // std::size_t
\r
14 #include <boost/type_traits/config.hpp>
\r
15 #include <boost/type_traits/detail/yes_no_type.hpp>
\r
16 #include <boost/type_traits/detail/ice_or.hpp>
\r
18 // should be the last #include
\r
19 #include <boost/type_traits/detail/bool_trait_def.hpp>
\r
23 template <class U, U x>
\r
26 template <typename T>
\r
27 struct has_new_operator_impl {
\r
29 static type_traits::yes_type check_sig(
\r
32 void *(*)(std::size_t),
\r
37 static type_traits::yes_type check_sig(
\r
40 void *(*)(std::size_t, const std::nothrow_t&),
\r
45 static type_traits::yes_type check_sig(
\r
48 void *(*)(std::size_t, void*),
\r
53 static type_traits::no_type check_sig(...);
\r
56 static type_traits::yes_type check_sig2(
\r
59 void *(*)(std::size_t),
\r
64 static type_traits::yes_type check_sig2(
\r
67 void *(*)(std::size_t, const std::nothrow_t&),
\r
72 static type_traits::yes_type check_sig2(
\r
75 void *(*)(std::size_t, void*),
\r
80 static type_traits::no_type check_sig2(...);
\r
82 // GCC2 won't even parse this template if we embed the computation
\r
83 // of s1 in the computation of value.
\r
85 BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(has_new_operator_impl<T>::template check_sig<T>(0)));
\r
86 BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(has_new_operator_impl<T>::template check_sig2<T>(0)));
\r
88 #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
\r
89 #pragma warning(push)
\r
90 #pragma warning(disable:6334)
\r
93 BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig<T>(0)));
\r
94 BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(check_sig2<T>(0)));
\r
96 #if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
\r
97 #pragma warning(pop)
\r
100 BOOST_STATIC_CONSTANT(bool, value =
\r
101 (::boost::type_traits::ice_or<
\r
102 (s1 == sizeof(type_traits::yes_type)),
\r
103 (s2 == sizeof(type_traits::yes_type))
\r
107 } // namespace detail
\r
109 BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_new_operator,T,::boost::detail::has_new_operator_impl<T>::value)
\r
111 } // namespace boost
\r
113 #include <boost/type_traits/detail/bool_trait_undef.hpp>
\r
115 #endif // BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
\r