1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Pablo Halpern 2009. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 //////////////////////////////////////////////////////////////////////////////
8 //
9 // (C) Copyright Ion Gaztanaga 2011-2014. Distributed under the Boost
10 // Software License, Version 1.0. (See accompanying file
11 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 //
13 // See http://www.boost.org/libs/intrusive for documentation.
14 //
15 //////////////////////////////////////////////////////////////////////////////
16 
17 #ifndef BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP
18 #define BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP
19 
20 #if defined(_MSC_VER)
21 #  pragma once
22 #endif
23 
24 #include <boost/intrusive/detail/workaround.hpp>
25 #include <boost/intrusive/detail/mpl.hpp>
26 #include <boost/intrusive/detail/preprocessor.hpp>
27 #include <boost/preprocessor/iteration/iterate.hpp>
28 
29 namespace boost {
30 namespace intrusive {
31 namespace detail {
32 
33 template <typename T>
addressof(T & obj)34 inline T* addressof(T& obj)
35 {
36    return static_cast<T*>
37       (static_cast<void*>
38          (const_cast<char*>
39             (&reinterpret_cast<const char&>(obj))
40          )
41       );
42 }
43 
44 template <typename T>
45 struct LowPriorityConversion
46 {
47     // Convertible from T with user-defined-conversion rank.
LowPriorityConversionboost::intrusive::detail::LowPriorityConversion48     LowPriorityConversion(const T&) { }
49 };
50 
51 }}}   //namespace boost::intrusive::detail
52 
53 #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
54 
55 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME pointer_to
56 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail {
57 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
58 #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>))
59 #include BOOST_PP_ITERATE()
60 
61 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME static_cast_from
62 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail {
63 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
64 #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>))
65 #include BOOST_PP_ITERATE()
66 
67 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME const_cast_from
68 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail {
69 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
70 #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>))
71 #include BOOST_PP_ITERATE()
72 
73 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME dynamic_cast_from
74 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace intrusive { namespace detail {
75 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END   }}}
76 #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, <boost/intrusive/detail/has_member_function_callable_with.hpp>))
77 #include BOOST_PP_ITERATE()
78 
79 namespace boost {
80 namespace intrusive {
81 namespace detail {
82 
83 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(element_type)
84 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type)
85 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference)
86 BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(value_traits_ptr)
87 
88 }  //namespace detail {
89 }  //namespace intrusive {
90 }  //namespace boost {
91 
92 #endif // ! defined(BOOST_INTRUSIVE_ALLOCATOR_MEMORY_UTIL_HPP)
93