blob: 2a5854d8c2b40c6506ad188eea57286f8457e40d [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2008-2012. 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// See http://www.boost.org/libs/container for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
10
11#ifndef BOOST_CONTAINER_DETAIL_PREPROCESSOR_HPP
12#define BOOST_CONTAINER_DETAIL_PREPROCESSOR_HPP
13
14#if (defined _MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif
17
18#include <ndnboost/container/detail/config_begin.hpp>
19#include <ndnboost/container/detail/workaround.hpp>
20#include <ndnboost/move/utility.hpp>
21
22#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
23//#error "This file is not needed when perfect forwarding is available"
24#endif //BOOST_CONTAINER_PERFECT_FORWARDING
25
26#include <ndnboost/preprocessor/iteration/local.hpp>
27#include <ndnboost/preprocessor/punctuation/paren_if.hpp>
28#include <ndnboost/preprocessor/punctuation/comma_if.hpp>
29#include <ndnboost/preprocessor/control/expr_if.hpp>
30#include <ndnboost/preprocessor/cat.hpp>
31#include <ndnboost/preprocessor/repetition/enum.hpp>
32#include <ndnboost/preprocessor/repetition/enum_params.hpp>
33#include <ndnboost/preprocessor/repetition/enum_trailing_params.hpp>
34#include <ndnboost/preprocessor/repetition/enum_trailing.hpp>
35#include <ndnboost/preprocessor/repetition/enum_shifted_params.hpp>
36#include <ndnboost/preprocessor/repetition/enum_shifted.hpp>
37#include <ndnboost/preprocessor/repetition/repeat.hpp>
38#include <ndnboost/preprocessor/logical/not.hpp>
39#include <ndnboost/preprocessor/arithmetic/sub.hpp>
40#include <ndnboost/preprocessor/arithmetic/add.hpp>
41#include <ndnboost/preprocessor/iteration/iterate.hpp>
42#include <ndnboost/move/utility.hpp>
43
44#define BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS 10
45
46//Note:
47//We define template parameters as const references to
48//be able to bind temporaries. After that we will un-const them.
49//This cast is ugly but it is necessary until "perfect forwarding"
50//is achieved in C++0x. Meanwhile, if we want to be able to
51//bind rvalues with non-const references, we have to be ugly
52#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
53 #define BOOST_CONTAINER_PP_PARAM_LIST(z, n, data) \
54 BOOST_PP_CAT(P, n) && BOOST_PP_CAT(p, n) \
55 //!
56#else
57 #define BOOST_CONTAINER_PP_PARAM_LIST(z, n, data) \
58 const BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n) \
59 //!
60#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
61
62#define BOOST_CONTAINER_PP_CONST_REF_PARAM_LIST_Q(z, n, Data) \
63const BOOST_PP_CAT(Q, n) & BOOST_PP_CAT(q, n) \
64//!
65
66#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
67 #define BOOST_CONTAINER_PP_PARAM(U, u) \
68 U && u \
69 //!
70#else
71 #define BOOST_CONTAINER_PP_PARAM(U, u) \
72 const U & u \
73 //!
74#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
75
76#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
77
78 #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
79 BOOST_PP_CAT(m_p, n) (::ndnboost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) )) \
80 //!
81
82#else //BOOST_NO_CXX11_RVALUE_REFERENCES
83
84 #define BOOST_CONTAINER_PP_PARAM_INIT(z, n, data) \
85 BOOST_PP_CAT(m_p, n) (const_cast<BOOST_PP_CAT(P, n) &>(BOOST_PP_CAT(p, n))) \
86 //!
87#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
88
89#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
90
91 #if defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
92
93 namespace ndnboost {
94 namespace container {
95 namespace container_detail {
96 template<class T>
97 struct ref_holder;
98
99 template<class T>
100 struct ref_holder<T &>
101 {
102 explicit ref_holder(T &t)
103 : t_(t)
104 {}
105 T &t_;
106 T & get() { return t_; }
107 };
108
109 template<class T>
110 struct ref_holder<const T>
111 {
112 explicit ref_holder(const T &t)
113 : t_(t)
114 {}
115 const T &t_;
116 const T & get() { return t_; }
117 };
118
119 template<class T>
120 struct ref_holder<const T &&>
121 {
122 explicit ref_holder(const T &t)
123 : t_(t)
124 {}
125 const T &t_;
126 const T & get() { return t_; }
127 };
128
129 template<class T>
130 struct ref_holder
131 {
132 explicit ref_holder(T &&t)
133 : t_(t)
134 {}
135 T &t_;
136 T && get() { return ::ndnboost::move(t_); }
137 };
138
139 template<class T>
140 struct ref_holder<T &&>
141 {
142 explicit ref_holder(T &&t)
143 : t_(t)
144 {}
145 T &t_;
146 T && get() { return ::ndnboost::move(t_); }
147 };
148
149 } //namespace container_detail {
150 } //namespace container {
151 } //namespace ndnboost {
152
153 #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \
154 ::ndnboost::container::container_detail::ref_holder<BOOST_PP_CAT(P, n)> BOOST_PP_CAT(m_p, n); \
155 //!
156
157 #else //BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG
158
159 #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \
160 BOOST_PP_CAT(P, n) && BOOST_PP_CAT(m_p, n); \
161 //!
162
163 #endif //defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
164
165#else //BOOST_NO_CXX11_RVALUE_REFERENCES
166
167 #define BOOST_CONTAINER_PP_PARAM_DEFINE(z, n, data) \
168 BOOST_PP_CAT(P, n) & BOOST_PP_CAT(m_p, n); \
169 //!
170#endif //#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
171
172#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
173
174 #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) BOOST_PP_CAT(this->m_p, n).get() \
175 //!
176
177#else //!defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
178
179 #define BOOST_CONTAINER_PP_MEMBER_FORWARD(z, n, data) \
180 ::ndnboost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(this->m_p, n) ) \
181 //!
182
183#endif //!defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && defined(BOOST_MOVE_MSVC_10_MEMBER_RVALUE_REF_BUG)
184
185#define BOOST_CONTAINER_PP_PARAM_INC(z, n, data) \
186 BOOST_PP_CAT(++this->m_p, n) \
187//!
188
189#define BOOST_CONTAINER_PP_IDENTITY(z, n, data) data
190
191
192#define BOOST_CONTAINER_PP_PARAM_FORWARD(z, n, data) \
193::ndnboost::forward< BOOST_PP_CAT(P, n) >( BOOST_PP_CAT(p, n) ) \
194//!
195
196#define BOOST_CONTAINER_PP_DECLVAL(z, n, data) \
197::ndnboost::move_detail::declval< BOOST_PP_CAT(P, n) >() \
198//!
199
200#define BOOST_CONTAINER_PP_MEMBER_IT_FORWARD(z, n, data) \
201BOOST_PP_CAT(*this->m_p, n) \
202//!
203
204#define BOOST_CONTAINER_PP_TEMPLATE_PARAM_VOID_DEFAULT(z, n, data) \
205 BOOST_PP_CAT(class P, n) = void \
206//!
207
208#define BOOST_CONTAINER_PP_TEMPLATE_PARAM_WITH_DEFAULT(z, n, default_type) \
209 BOOST_PP_CAT(class P, n) = default_type \
210//!
211
212#define BOOST_CONTAINER_PP_STATIC_PARAM_REF_DECLARE(z, n, data) \
213 static BOOST_PP_CAT(P, n) & BOOST_PP_CAT(p, n); \
214//!
215
216#define BOOST_CONTAINER_PP_PARAM_PASS(z, n, data) \
217 BOOST_PP_CAT(p, n) \
218//!
219
220#define BOOST_CONTAINER_PP_FWD_TYPE(z, n, data) \
221 typename ::ndnboost::move_detail::forward_type< BOOST_PP_CAT(P, n) >::type \
222//!
223
224#include <ndnboost/container/detail/config_end.hpp>
225
226//#else
227
228//#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
229//#error "This file is not needed when perfect forwarding is available"
230//#endif //BOOST_CONTAINER_PERFECT_FORWARDING
231
232#endif //#ifndef BOOST_CONTAINER_DETAIL_PREPROCESSOR_HPP