////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Pablo Halpern 2009. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // ////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/intrusive for documentation. // ////////////////////////////////////////////////////////////////////////////// #ifndef BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP #define BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP #if (defined _MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif #include #include #include #include namespace boost { namespace intrusive { namespace detail { template inline T* addressof(T& obj) { return static_cast (static_cast (const_cast (&reinterpret_cast(obj)) ) ); } template struct unvoid { typedef T type; }; template <> struct unvoid { struct type { }; }; template <> struct unvoid { struct type { }; }; template struct LowPriorityConversion { // Convertible from T with user-defined-conversion rank. LowPriorityConversion(const T&) { } }; // Infrastructure for providing a default type for T::TNAME if absent. #define BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(TNAME) \ template \ struct boost_intrusive_default_type_ ## TNAME \ { \ template \ static char test(int, typename X::TNAME*); \ \ template \ static int test(boost::intrusive::detail:: \ LowPriorityConversion, void*); \ \ struct DefaultWrap { typedef DefaultType TNAME; }; \ \ static const bool value = (1 == sizeof(test(0, 0))); \ \ typedef typename \ ::boost::intrusive::detail::if_c \ ::type::TNAME type; \ }; \ \ template \ struct boost_intrusive_eval_default_type_ ## TNAME \ { \ template \ static char test(int, typename X::TNAME*); \ \ template \ static int test(boost::intrusive::detail:: \ LowPriorityConversion, void*); \ \ struct DefaultWrap \ { typedef typename DefaultType::type TNAME; }; \ \ static const bool value = (1 == sizeof(test(0, 0))); \ \ typedef typename \ ::boost::intrusive::detail::eval_if_c \ < value \ , ::boost::intrusive::detail::identity \ , ::boost::intrusive::detail::identity \ >::type::TNAME type; \ }; \ // #define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \ typename INSTANTIATION_NS_PREFIX \ boost_intrusive_default_type_ ## TNAME< T, TIMPL >::type \ // #define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \ typename INSTANTIATION_NS_PREFIX \ boost_intrusive_eval_default_type_ ## TNAME< T, TIMPL >::type \ // }}} //namespace boost::intrusive::detail #include #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME pointer_to #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 1, )) #include BOOST_PP_ITERATE() #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME static_cast_from #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 1, )) #include BOOST_PP_ITERATE() #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME const_cast_from #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 1, )) #include BOOST_PP_ITERATE() #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME dynamic_cast_from #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail { #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 1, )) #include BOOST_PP_ITERATE() namespace boost { namespace intrusive { namespace detail { BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(element_type) BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) ////////////////////// //struct first_param ////////////////////// template struct first_param { typedef void type; }; #if !defined(BOOST_NO_VARIADIC_TEMPLATES) template