1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2008-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)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_DETAIL_PREPROCESSOR_HPP
12 #define BOOST_INTERPROCESS_DETAIL_PREPROCESSOR_HPP
14 #if (defined _MSC_VER) && (_MSC_VER >= 1200)
18 #include "config_begin.hpp"
20 #ifdef BOOST_INTERPROCESS_PERFECT_FORWARDING
21 #error "This file is not needed when perfect forwarding is available"
24 #include <boost/preprocessor/iteration/local.hpp>
25 #include <boost/preprocessor/repetition/enum_params.hpp>
26 #include <boost/preprocessor/cat.hpp>
27 #include <boost/preprocessor/repetition/enum.hpp>
28 #include <boost/preprocessor/repetition/repeat.hpp>
30 #define BOOST_INTERPROCESS_MAX_CONSTRUCTOR_PARAMETERS 10
33 //We define template parameters as const references to
34 //be able to bind temporaries. After that we will un-const them.
35 //This cast is ugly but it is necessary until "perfect forwarding"
36 //is achieved in C++0x. Meanwhile, if we want to be able to
37 //bind rvalues with non-const references, we have to be ugly
38 #ifndef BOOST_NO_RVALUE_REFERENCES
39 #define BOOST_INTERPROCESS_PP_PARAM_LIST(z, n, data) \
40 BOOST_PP_CAT(P, n) && BOOST_PP_CAT(p, n) \
43 #define BOOST_INTERPROCESS_PP_PARAM_LIST(z, n, data) \
44 const BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n) \
48 #ifndef BOOST_NO_RVALUE_REFERENCES
49 #define BOOST_INTERPROCESS_PARAM(U, u) \
53 #define BOOST_INTERPROCESS_PARAM(U, u) \
58 #ifndef BOOST_NO_RVALUE_REFERENCES
60 #ifdef BOOST_MOVE_OLD_RVALUE_REF_BINDING_RULES
62 #define BOOST_INTERPROCESS_AUX_PARAM_INIT(z, n, data) \
63 BOOST_PP_CAT(m_p, n) (BOOST_INTERPROCESS_MOVE_NAMESPACE::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) )) \
68 #define BOOST_INTERPROCESS_AUX_PARAM_INIT(z, n, data) \
69 BOOST_PP_CAT(m_p, n) (BOOST_PP_CAT(p, n)) \
75 #define BOOST_INTERPROCESS_AUX_PARAM_INIT(z, n, data) \
76 BOOST_PP_CAT(m_p, n) (const_cast<BOOST_PP_CAT(P, n) &>(BOOST_PP_CAT(p, n))) \
80 #define BOOST_INTERPROCESS_AUX_PARAM_INC(z, n, data) \
81 BOOST_PP_CAT(++m_p, n) \
84 #ifndef BOOST_NO_RVALUE_REFERENCES
86 #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
88 #define BOOST_INTERPROCESS_AUX_PARAM_DEFINE(z, n, data) \
89 BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \
94 #define BOOST_INTERPROCESS_AUX_PARAM_DEFINE(z, n, data) \
95 BOOST_PP_CAT(P, n) && BOOST_PP_CAT(m_p, n); \
98 #endif //defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
102 #define BOOST_INTERPROCESS_AUX_PARAM_DEFINE(z, n, data) \
103 BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \
107 #define BOOST_INTERPROCESS_PP_PARAM_FORWARD(z, n, data) \
108 ::boost::interprocess::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ) \
111 #if !defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
113 #include <boost/container/detail/stored_ref.hpp>
115 #define BOOST_INTERPROCESS_PP_MEMBER_FORWARD(z, n, data) \
116 ::boost::container::containers_detail::stored_ref< BOOST_PP_CAT(P, n) >::forward( BOOST_PP_CAT(m_p, n) ) \
121 #define BOOST_INTERPROCESS_PP_MEMBER_FORWARD(z, n, data) \
122 ::boost::interprocess::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(m_p, n) ) \
125 #endif //!defined(BOOST_NO_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
127 #define BOOST_INTERPROCESS_PP_MEMBER_IT_FORWARD(z, n, data) \
128 BOOST_PP_CAT(*m_p, n) \
131 #include <boost/interprocess/detail/config_end.hpp>
134 #ifdef BOOST_INTERPROCESS_PERFECT_FORWARDING
135 #error "This file is not needed when perfect forwarding is available"
137 #endif //#ifndef BOOST_INTERPROCESS_DETAIL_PREPROCESSOR_HPP