2 // (C) Copyright Runar Undheim, Robert Ramey & John Maddock 2008.
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_NEW_OPERATOR_HPP_INCLUDED
10 #define BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
12 #include <new> // std::nothrow_t
13 #include <cstddef> // std::size_t
14 #include <boost/type_traits/config.hpp>
15 #include <boost/type_traits/detail/yes_no_type.hpp>
16 #include <boost/type_traits/detail/ice_or.hpp>
18 // should be the last #include
19 #include <boost/type_traits/detail/bool_trait_def.hpp>
23 template <class U
, U x
>
27 struct has_new_operator_impl
{
29 static type_traits::yes_type
check_sig(
32 void *(*)(std::size_t),
37 static type_traits::yes_type
check_sig(
40 void *(*)(std::size_t, const std::nothrow_t
&),
45 static type_traits::yes_type
check_sig(
48 void *(*)(std::size_t, void*),
53 static type_traits::no_type
check_sig(...);
56 static type_traits::yes_type
check_sig2(
59 void *(*)(std::size_t),
64 static type_traits::yes_type
check_sig2(
67 void *(*)(std::size_t, const std::nothrow_t
&),
72 static type_traits::yes_type
check_sig2(
75 void *(*)(std::size_t, void*),
80 static type_traits::no_type
check_sig2(...);
82 // GCC2 won't even parse this template if we embed the computation
83 // of s1 in the computation of value.
85 BOOST_STATIC_CONSTANT(unsigned, s1
= sizeof(has_new_operator_impl
<T
>::template check_sig
<T
>(0)));
86 BOOST_STATIC_CONSTANT(unsigned, s2
= sizeof(has_new_operator_impl
<T
>::template check_sig2
<T
>(0)));
88 #if BOOST_WORKAROUND(_MSC_FULL_VER, >= 140050000)
90 #pragma warning(disable:6334)
93 BOOST_STATIC_CONSTANT(unsigned, s1
= sizeof(check_sig
<T
>(0)));
94 BOOST_STATIC_CONSTANT(unsigned, s2
= sizeof(check_sig2
<T
>(0)));
96 #if BOOST_WORKAROUND(_MSC_FULL_VER, >= 140050000)
100 BOOST_STATIC_CONSTANT(bool, value
=
101 (::boost::type_traits::ice_or
<
102 (s1
== sizeof(type_traits::yes_type
)),
103 (s2
== sizeof(type_traits::yes_type
))
107 } // namespace detail
109 BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_new_operator
,T
,::boost::detail::has_new_operator_impl
<T
>::value
)
113 #include <boost/type_traits/detail/bool_trait_undef.hpp>
115 #endif // BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED