Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/log/detail/light_function_pp.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 /* | 1 /* |
2 * Copyright Andrey Semashev 2007 - 2013. | 2 * Copyright Andrey Semashev 2007 - 2015. |
3 * Distributed under the Boost Software License, Version 1.0. | 3 * Distributed under the Boost Software License, Version 1.0. |
4 * (See accompanying file LICENSE_1_0.txt or copy at | 4 * (See accompanying file LICENSE_1_0.txt or copy at |
5 * http://www.boost.org/LICENSE_1_0.txt) | 5 * http://www.boost.org/LICENSE_1_0.txt) |
6 */ | 6 */ |
7 | 7 |
18 typedef ResultT result_type; | 18 typedef ResultT result_type; |
19 | 19 |
20 private: | 20 private: |
21 struct impl_base | 21 struct impl_base |
22 { | 22 { |
23 typedef result_type (*invoke_type)(impl_base* BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), ArgT)); | 23 typedef result_type (*invoke_type)(void* BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), ArgT)); |
24 const invoke_type invoke; | 24 const invoke_type invoke; |
25 | 25 |
26 typedef impl_base* (*clone_type)(const impl_base*); | 26 typedef impl_base* (*clone_type)(const void*); |
27 const clone_type clone; | 27 const clone_type clone; |
28 | 28 |
29 typedef void (*destroy_type)(impl_base*); | 29 typedef void (*destroy_type)(void*); |
30 const destroy_type destroy; | 30 const destroy_type destroy; |
31 | 31 |
32 impl_base(invoke_type inv, clone_type cl, destroy_type dstr) : invoke(inv), clone(cl), destroy(dstr) | 32 impl_base(invoke_type inv, clone_type cl, destroy_type dstr) : invoke(inv), clone(cl), destroy(dstr) |
33 { | 33 { |
34 } | 34 } |
35 | |
36 BOOST_DELETED_FUNCTION(impl_base(impl_base const&)) | |
37 BOOST_DELETED_FUNCTION(impl_base& operator= (impl_base const&)) | |
35 }; | 38 }; |
36 | 39 |
37 #if !defined(BOOST_LOG_NO_MEMBER_TEMPLATE_FRIENDS) | 40 #if !defined(BOOST_LOG_NO_MEMBER_TEMPLATE_FRIENDS) |
38 template< typename FunT > | 41 template< typename FunT > |
39 class impl; | 42 class impl; |
57 } | 60 } |
58 | 61 |
59 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) | 62 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
60 explicit impl(FunT&& fun) : | 63 explicit impl(FunT&& fun) : |
61 impl_base(&this_type::invoke_impl, &this_type::clone_impl, &this_type::destroy_impl), | 64 impl_base(&this_type::invoke_impl, &this_type::clone_impl, &this_type::destroy_impl), |
62 m_Function(fun) | 65 m_Function(boost::move(fun)) |
63 { | 66 { |
64 } | 67 } |
65 #endif // !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) | 68 #endif // !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
66 | 69 |
67 static void destroy_impl(impl_base* self) | 70 static void destroy_impl(void* self) |
68 { | 71 { |
69 delete static_cast< impl* >(self); | 72 delete static_cast< impl* >(static_cast< impl_base* >(self)); |
70 } | 73 } |
71 static impl_base* clone_impl(const impl_base* self) | 74 static impl_base* clone_impl(const void* self) |
72 { | 75 { |
73 return new impl(static_cast< const impl* >(self)->m_Function); | 76 return new impl(static_cast< const impl* >(static_cast< const impl_base* >(self))->m_Function); |
74 } | 77 } |
75 static result_type invoke_impl(impl_base* self BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PP_ITERATION(), ArgT, arg)) | 78 static result_type invoke_impl(void* self BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PP_ITERATION(), ArgT, arg)) |
76 { | 79 { |
77 return static_cast< impl* >(self)->m_Function(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), arg)); | 80 return static_cast< impl* >(static_cast< impl_base* >(self))->m_Function(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), arg)); |
78 } | 81 } |
82 | |
83 BOOST_DELETED_FUNCTION(impl(impl const&)) | |
84 BOOST_DELETED_FUNCTION(impl& operator= (impl const&)) | |
79 }; | 85 }; |
80 | 86 |
81 private: | 87 private: |
82 impl_base* m_pImpl; | 88 impl_base* m_pImpl; |
83 | 89 |
111 m_pImpl(new impl< typename remove_cv< typename remove_reference< FunT >::type >::type >(boost::forward< FunT >(fun))) | 117 m_pImpl(new impl< typename remove_cv< typename remove_reference< FunT >::type >::type >(boost::forward< FunT >(fun))) |
112 { | 118 { |
113 } | 119 } |
114 #else | 120 #else |
115 template< typename FunT > | 121 template< typename FunT > |
116 light_function(FunT const& fun, typename disable_if< mpl::or_< move_detail::is_rv< FunT >, is_same< FunT, this_type > >, int >::type = 0) : | 122 light_function(FunT const& fun, typename disable_if_c< is_rv_or_same< FunT, this_type >::value, int >::type = 0) : |
117 m_pImpl(new impl< FunT >(fun)) | 123 m_pImpl(new impl< FunT >(fun)) |
118 { | 124 { |
119 } | 125 } |
120 template< typename FunT > | 126 template< typename FunT > |
121 light_function(rv< FunT > const& fun, typename disable_if< is_same< typename remove_cv< FunT >::type, this_type >, int >::type = 0) : | 127 light_function(BOOST_RV_REF(FunT) fun, typename disable_if_c< is_cv_same< FunT, this_type >::value, int >::type = 0) : |
122 m_pImpl(new impl< typename remove_cv< FunT >::type >(fun)) | 128 m_pImpl(new impl< typename remove_cv< FunT >::type >(fun)) |
123 { | 129 { |
124 } | 130 } |
125 #endif | 131 #endif |
126 | 132 |
146 this->swap(that); | 152 this->swap(that); |
147 return *this; | 153 return *this; |
148 } | 154 } |
149 light_function& operator= (BOOST_COPY_ASSIGN_REF(this_type) that) | 155 light_function& operator= (BOOST_COPY_ASSIGN_REF(this_type) that) |
150 { | 156 { |
151 light_function tmp = that; | 157 light_function tmp = static_cast< this_type const& >(that); |
152 this->swap(tmp); | 158 this->swap(tmp); |
153 return *this; | 159 return *this; |
154 } | 160 } |
155 //! Assignment of NULL | 161 //! Assignment of NULL |
156 #if !defined(BOOST_NO_CXX11_NULLPTR) | 162 #if !defined(BOOST_NO_CXX11_NULLPTR) |
173 this->swap(tmp); | 179 this->swap(tmp); |
174 return *this; | 180 return *this; |
175 } | 181 } |
176 #else | 182 #else |
177 template< typename FunT > | 183 template< typename FunT > |
178 typename disable_if< mpl::or_< move_detail::is_rv< FunT >, is_same< FunT, this_type > >, this_type& >::type | 184 typename disable_if_c< is_rv_or_same< FunT, this_type >::value, this_type& >::type |
179 operator= (FunT const& fun) | 185 operator= (FunT const& fun) |
180 { | 186 { |
181 light_function tmp(fun); | 187 light_function tmp(fun); |
182 this->swap(tmp); | 188 this->swap(tmp); |
183 return *this; | 189 return *this; |
187 result_type operator() (BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), ArgT, arg)) const | 193 result_type operator() (BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), ArgT, arg)) const |
188 { | 194 { |
189 return m_pImpl->invoke(m_pImpl BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), arg)); | 195 return m_pImpl->invoke(m_pImpl BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), arg)); |
190 } | 196 } |
191 | 197 |
192 BOOST_EXPLICIT_OPERATOR_BOOL() | 198 BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT() |
193 bool operator! () const BOOST_NOEXCEPT { return (m_pImpl == NULL); } | 199 bool operator! () const BOOST_NOEXCEPT { return (m_pImpl == NULL); } |
194 bool empty() const BOOST_NOEXCEPT { return (m_pImpl == NULL); } | 200 bool empty() const BOOST_NOEXCEPT { return (m_pImpl == NULL); } |
195 void clear() BOOST_NOEXCEPT | 201 void clear() BOOST_NOEXCEPT |
196 { | 202 { |
197 if (m_pImpl) | 203 if (m_pImpl) |
201 } | 207 } |
202 } | 208 } |
203 | 209 |
204 void swap(this_type& that) BOOST_NOEXCEPT | 210 void swap(this_type& that) BOOST_NOEXCEPT |
205 { | 211 { |
206 register impl_base* p = m_pImpl; | 212 impl_base* p = m_pImpl; |
207 m_pImpl = that.m_pImpl; | 213 m_pImpl = that.m_pImpl; |
208 that.m_pImpl = p; | 214 that.m_pImpl = p; |
209 } | 215 } |
210 }; | 216 }; |
211 | 217 |
221 typedef void result_type; | 227 typedef void result_type; |
222 | 228 |
223 private: | 229 private: |
224 struct impl_base | 230 struct impl_base |
225 { | 231 { |
226 typedef void (*invoke_type)(impl_base* BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), ArgT)); | 232 typedef void (*invoke_type)(void* BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), ArgT)); |
227 const invoke_type invoke; | 233 const invoke_type invoke; |
228 | 234 |
229 typedef impl_base* (*clone_type)(const impl_base*); | 235 typedef impl_base* (*clone_type)(const void*); |
230 const clone_type clone; | 236 const clone_type clone; |
231 | 237 |
232 typedef void (*destroy_type)(impl_base*); | 238 typedef void (*destroy_type)(void*); |
233 const destroy_type destroy; | 239 const destroy_type destroy; |
234 | 240 |
235 impl_base(invoke_type inv, clone_type cl, destroy_type dstr) : invoke(inv), clone(cl), destroy(dstr) | 241 impl_base(invoke_type inv, clone_type cl, destroy_type dstr) : invoke(inv), clone(cl), destroy(dstr) |
236 { | 242 { |
237 } | 243 } |
244 | |
245 BOOST_DELETED_FUNCTION(impl_base(impl_base const&)) | |
246 BOOST_DELETED_FUNCTION(impl_base& operator= (impl_base const&)) | |
238 }; | 247 }; |
239 | 248 |
240 #if !defined(BOOST_LOG_NO_MEMBER_TEMPLATE_FRIENDS) | 249 #if !defined(BOOST_LOG_NO_MEMBER_TEMPLATE_FRIENDS) |
241 template< typename FunT > | 250 template< typename FunT > |
242 class impl; | 251 class impl; |
260 } | 269 } |
261 | 270 |
262 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) | 271 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
263 explicit impl(FunT&& fun) : | 272 explicit impl(FunT&& fun) : |
264 impl_base(&this_type::invoke_impl, &this_type::clone_impl, &this_type::destroy_impl), | 273 impl_base(&this_type::invoke_impl, &this_type::clone_impl, &this_type::destroy_impl), |
265 m_Function(fun) | 274 m_Function(boost::move(fun)) |
266 { | 275 { |
267 } | 276 } |
268 #endif // !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) | 277 #endif // !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
269 | 278 |
270 static void destroy_impl(impl_base* self) | 279 static void destroy_impl(void* self) |
271 { | 280 { |
272 delete static_cast< impl* >(self); | 281 delete static_cast< impl* >(static_cast< impl_base* >(self)); |
273 } | 282 } |
274 static impl_base* clone_impl(const impl_base* self) | 283 static impl_base* clone_impl(const void* self) |
275 { | 284 { |
276 return new impl(static_cast< const impl* >(self)->m_Function); | 285 return new impl(static_cast< const impl* >(static_cast< const impl_base* >(self))->m_Function); |
277 } | 286 } |
278 static result_type invoke_impl(impl_base* self BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PP_ITERATION(), ArgT, arg)) | 287 static result_type invoke_impl(void* self BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PP_ITERATION(), ArgT, arg)) |
279 { | 288 { |
280 static_cast< impl* >(self)->m_Function(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), arg)); | 289 static_cast< impl* >(static_cast< impl_base* >(self))->m_Function(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), arg)); |
281 } | 290 } |
291 | |
292 BOOST_DELETED_FUNCTION(impl(impl const&)) | |
293 BOOST_DELETED_FUNCTION(impl& operator= (impl const&)) | |
282 }; | 294 }; |
283 | 295 |
284 private: | 296 private: |
285 impl_base* m_pImpl; | 297 impl_base* m_pImpl; |
286 | 298 |
313 m_pImpl(new impl< typename remove_cv< typename remove_reference< FunT >::type >::type >(boost::forward< FunT >(fun))) | 325 m_pImpl(new impl< typename remove_cv< typename remove_reference< FunT >::type >::type >(boost::forward< FunT >(fun))) |
314 { | 326 { |
315 } | 327 } |
316 #else | 328 #else |
317 template< typename FunT > | 329 template< typename FunT > |
318 light_function(FunT const& fun, typename disable_if< mpl::or_< move_detail::is_rv< FunT >, is_same< FunT, this_type > >, int >::type = 0) : | 330 light_function(FunT const& fun, typename disable_if_c< is_rv_or_same< FunT, this_type >::value, int >::type = 0) : |
319 m_pImpl(new impl< FunT >(fun)) | 331 m_pImpl(new impl< FunT >(fun)) |
320 { | 332 { |
321 } | 333 } |
322 template< typename FunT > | 334 template< typename FunT > |
323 light_function(rv< FunT > const& fun, typename disable_if< is_same< typename remove_cv< FunT >::type, this_type >, int >::type = 0) : | 335 light_function(BOOST_RV_REF(FunT) fun, typename disable_if_c< is_cv_same< FunT, this_type >::value, int >::type = 0) : |
324 m_pImpl(new impl< typename remove_cv< FunT >::type >(fun)) | 336 m_pImpl(new impl< typename remove_cv< FunT >::type >(fun)) |
325 { | 337 { |
326 } | 338 } |
327 #endif | 339 #endif |
328 | 340 |
348 this->swap(that); | 360 this->swap(that); |
349 return *this; | 361 return *this; |
350 } | 362 } |
351 light_function& operator= (BOOST_COPY_ASSIGN_REF(this_type) that) | 363 light_function& operator= (BOOST_COPY_ASSIGN_REF(this_type) that) |
352 { | 364 { |
353 light_function tmp = that; | 365 light_function tmp = static_cast< this_type const& >(that); |
354 this->swap(tmp); | 366 this->swap(tmp); |
355 return *this; | 367 return *this; |
356 } | 368 } |
357 //! Assignment of NULL | 369 //! Assignment of NULL |
358 #if !defined(BOOST_NO_CXX11_NULLPTR) | 370 #if !defined(BOOST_NO_CXX11_NULLPTR) |
375 this->swap(tmp); | 387 this->swap(tmp); |
376 return *this; | 388 return *this; |
377 } | 389 } |
378 #else | 390 #else |
379 template< typename FunT > | 391 template< typename FunT > |
380 typename disable_if< mpl::or_< move_detail::is_rv< FunT >, is_same< FunT, this_type > >, this_type& >::type | 392 typename disable_if_c< is_rv_or_same< FunT, this_type >::value, this_type& >::type |
381 operator= (FunT const& fun) | 393 operator= (FunT const& fun) |
382 { | 394 { |
383 light_function tmp(fun); | 395 light_function tmp(fun); |
384 this->swap(tmp); | 396 this->swap(tmp); |
385 return *this; | 397 return *this; |
389 result_type operator() (BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), ArgT, arg)) const | 401 result_type operator() (BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), ArgT, arg)) const |
390 { | 402 { |
391 m_pImpl->invoke(m_pImpl BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), arg)); | 403 m_pImpl->invoke(m_pImpl BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), arg)); |
392 } | 404 } |
393 | 405 |
394 BOOST_EXPLICIT_OPERATOR_BOOL() | 406 BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT() |
395 bool operator! () const BOOST_NOEXCEPT { return (m_pImpl == NULL); } | 407 bool operator! () const BOOST_NOEXCEPT { return (m_pImpl == NULL); } |
396 bool empty() const BOOST_NOEXCEPT { return (m_pImpl == NULL); } | 408 bool empty() const BOOST_NOEXCEPT { return (m_pImpl == NULL); } |
397 void clear() BOOST_NOEXCEPT | 409 void clear() BOOST_NOEXCEPT |
398 { | 410 { |
399 if (m_pImpl) | 411 if (m_pImpl) |
403 } | 415 } |
404 } | 416 } |
405 | 417 |
406 void swap(this_type& that) BOOST_NOEXCEPT | 418 void swap(this_type& that) BOOST_NOEXCEPT |
407 { | 419 { |
408 register impl_base* p = m_pImpl; | 420 impl_base* p = m_pImpl; |
409 m_pImpl = that.m_pImpl; | 421 m_pImpl = that.m_pImpl; |
410 that.m_pImpl = p; | 422 that.m_pImpl = p; |
411 } | 423 } |
412 }; | 424 }; |