1 |
|
---|
2 | // (C) Copyright Runar Undheim, Robert Ramey & 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_NEW_OPERATOR_HPP_INCLUDED
|
---|
10 | #define BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
|
---|
11 |
|
---|
12 | #include <boost/type_traits/config.hpp>
|
---|
13 | #include <boost/type_traits/intrinsics.hpp>
|
---|
14 | #include <boost/type_traits/is_pod.hpp>
|
---|
15 | #include <boost/type_traits/detail/ice_or.hpp>
|
---|
16 |
|
---|
17 | // should be the last #include
|
---|
18 | #include <boost/type_traits/detail/bool_trait_def.hpp>
|
---|
19 |
|
---|
20 | namespace boost {
|
---|
21 | namespace detail {
|
---|
22 | template <class U, U x>
|
---|
23 | struct test;
|
---|
24 |
|
---|
25 | template <typename T>
|
---|
26 | struct has_new_operator_impl {
|
---|
27 | template<class U>
|
---|
28 | static type_traits::yes_type check_sig(
|
---|
29 | U*,
|
---|
30 | test<
|
---|
31 | void *(*)(size_t),
|
---|
32 | &U::operator new
|
---|
33 | >* = NULL
|
---|
34 | );
|
---|
35 | template<class U>
|
---|
36 | static type_traits::no_type check_sig(...);
|
---|
37 |
|
---|
38 | // GCC2 won't even parse this template if we embed the computation
|
---|
39 | // of s1 in the computation of value.
|
---|
40 | #ifdef __GNUC__
|
---|
41 | BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(has_new_operator<T>::template check_sig<T>(0)));
|
---|
42 | #else
|
---|
43 | #if BOOST_WORKAROUND(_MSC_FULL_VER, >= 140050000)
|
---|
44 | #pragma warning(push)
|
---|
45 | #pragma warning(disable:6334)
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | BOOST_STATIC_CONSTANT(unsigned, s1 = sizeof(check_sig<T>(0)));
|
---|
49 |
|
---|
50 | #if BOOST_WORKAROUND(_MSC_FULL_VER, >= 140050000)
|
---|
51 | #pragma warning(pop)
|
---|
52 | #endif
|
---|
53 | #endif
|
---|
54 | BOOST_STATIC_CONSTANT(bool, value = (s1 == sizeof(type_traits::yes_type)));
|
---|
55 | };
|
---|
56 | } // namespace detail
|
---|
57 |
|
---|
58 | BOOST_TT_AUX_BOOL_TRAIT_DEF1(has_new_operator,T,::boost::detail::has_new_operator_impl<T>::value)
|
---|
59 |
|
---|
60 | } // namespace boost
|
---|
61 |
|
---|
62 | #include <boost/type_traits/detail/bool_trait_undef.hpp>
|
---|
63 |
|
---|
64 | #endif // BOOST_TT_HAS_NEW_OPERATOR_HPP_INCLUDED
|
---|