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_sig1(
32
void *(*)(std::size_t),
37
static type_traits::no_type check_sig1(...);
40
static type_traits::yes_type check_sig2(
43
void *(*)(std::size_t, const std::nothrow_t&),
48
static type_traits::no_type check_sig2(...);
51
static type_traits::yes_type check_sig3(
54
void *(*)(std::size_t, void*),
59
static type_traits::no_type check_sig3(...);
63
static type_traits::yes_type check_sig4(
66
void *(*)(std::size_t),
71
static type_traits::no_type check_sig4(...);
74
static type_traits::yes_type check_sig5(
77
void *(*)(std::size_t, const std::nothrow_t&),
82
static type_traits::no_type check_sig5(...);
85
static type_traits::yes_type check_sig6(
88
void *(*)(std::size_t, void*),
93
static type_traits::no_type check_sig6(...);
95
// GCC2 won't even parse this template if we embed the computation
96
// of s1 in the computation of value.
98
BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(has_new_operator_impl<T>::template check_sig1<T>(0)));
99
BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(has_new_operator_impl<T>::template check_sig2<T>(0)));
100
BOOST_STATIC_CONSTANT(unsigned, s3 = sizeof(has_new_operator_impl<T>::template check_sig3<T>(0)));
101
BOOST_STATIC_CONSTANT(unsigned, s4 = sizeof(has_new_operator_impl<T>::template check_sig4<T>(0)));
102
BOOST_STATIC_CONSTANT(unsigned, s5 = sizeof(has_new_operator_impl<T>::template check_sig5<T>(0)));
103
BOOST_STATIC_CONSTANT(unsigned, s6 = sizeof(has_new_operator_impl<T>::template check_sig6<T>(0)));
105
#if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
106
#pragma warning(push)
107
#pragma warning(disable:6334)
110
BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig1<T>(0)));
111
BOOST_STATIC_CONSTANT(unsigned, s2 = sizeof(check_sig2<T>(0)));
112
BOOST_STATIC_CONSTANT(unsigned, s3 = sizeof(check_sig3<T>(0)));
113
BOOST_STATIC_CONSTANT(unsigned, s4 = sizeof(check_sig4<T>(0)));
114
BOOST_STATIC_CONSTANT(unsigned, s5 = sizeof(check_sig5<T>(0)));
115
BOOST_STATIC_CONSTANT(unsigned, s6 = sizeof(check_sig6<T>(0)));
117
#if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
121
BOOST_STATIC_CONSTANT(bool, value =
122
(::boost::type_traits::ice_or<
123
(s1 == sizeof(type_traits::yes_type)),
124
(s2 == sizeof(type_traits::yes_type)),
125
(s3 == sizeof(type_traits::yes_type)),
126
(s4 == sizeof(type_traits::yes_type)),
127
(s5 == sizeof(type_traits::yes_type)),
128
(s6 == sizeof(type_traits::yes_type))
132
} // namespace detail
134
BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_new_operator,T,::boost::detail::has_new_operator_impl<T>::value)
138
#include <boost/type_traits/detail/bool_trait_undef.hpp>
140
#endif // BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED