|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77389 - in trunk: boost boost/local_function/aux_/macro/code_ libs/scope_exit/test
From: lorcaminiti_at_[hidden]
Date: 2012-03-18 17:53:40
Author: lcaminiti
Date: 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
New Revision: 77389
URL: http://svn.boost.org/trac/boost/changeset/77389
Log:
Fixed a bug in capturing this_ that caused ScopeExit tests to fail with an internal error on old GCCs for templates (now this type is deduced within a struct like all other type captures to workaround this). Added a test for this case (..._this_tpl.cpp).
Fixed a bug that omitted `= {}` when this_ was the only ScopeExit captured variable (now generating `= {}` even when only this_ is captured).
Fixed LocalFunction to work with the above ScopeExit fixes (some of which required changes to ScopeExit protected macro interface).
Added:
trunk/libs/scope_exit/test/native_this_tpl.cpp (contents, props changed)
Text files modified:
trunk/boost/local_function/aux_/macro/code_/bind.hpp | 50 +++--
trunk/boost/local_function/aux_/macro/code_/functor.hpp | 39 ++--
trunk/boost/scope_exit.hpp | 309 +++++++++++++++++++++++++++------------
trunk/libs/scope_exit/test/Jamfile.v2 | 3
trunk/libs/scope_exit/test/native_this.cpp | 16 +
trunk/libs/scope_exit/test/world_checkpoint_all.cpp | 4
trunk/libs/scope_exit/test/world_checkpoint_all_seq.cpp | 4
trunk/libs/scope_exit/test/world_this.cpp | 8 -
trunk/libs/scope_exit/test/world_this_seq.cpp | 6
9 files changed, 278 insertions(+), 161 deletions(-)
Modified: trunk/boost/local_function/aux_/macro/code_/bind.hpp
==============================================================================
--- trunk/boost/local_function/aux_/macro/code_/bind.hpp (original)
+++ trunk/boost/local_function/aux_/macro/code_/bind.hpp 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
@@ -64,11 +64,7 @@
id \
, \
/* ScopeExit expects typename or EMPTY() here */ \
- BOOST_PP_IIF(typename01, \
- BOOST_PP_IDENTITY(typename) \
- , \
- BOOST_PP_EMPTY \
- )() \
+ BOOST_PP_EXPR_IIF(typename01, typename) \
), \
i, BOOST_LOCAL_FUNCTION_AUX_PP_BIND_TRAITS_VAR_WITHOUT_TYPE( \
bind_traits))
@@ -90,11 +86,9 @@
BOOST_PP_TUPLE_ELEM(2, 0, id_typename) \
, \
/* ScopeExit expects typename or EMPTY() here */ \
- BOOST_PP_IIF(BOOST_PP_TUPLE_ELEM(2, 1, id_typename), \
- BOOST_PP_IDENTITY(typename) \
- , \
- BOOST_PP_EMPTY \
- )() \
+ BOOST_PP_EXPR_IIF(BOOST_PP_TUPLE_ELEM(2, 1, id_typename), \
+ typename \
+ ) \
), \
i, BOOST_LOCAL_FUNCTION_AUX_PP_BIND_TRAITS_VAR_WITHOUT_TYPE( \
bind_traits))
@@ -123,21 +117,28 @@
BOOST_LOCAL_FUNCTION_AUX_PP_BIND_TRAITS_VAR_WITHOUT_TYPE( \
bind_traits))
+#define BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_CAPTURE_TYPE_(id) \
+ BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (this_capture_type)(id) )
+
+#define BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE_(id) \
+ BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (this_type)(id) )
+
#define BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPEDEF_DEDUCED_( \
- id, all_bind_this_types) \
+ id, typename01, all_bind_this_types) \
BOOST_SCOPE_EXIT_DETAIL_TYPEDEF_TYPEOF_THIS(id, \
- BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id))
+ BOOST_PP_EXPR_IIF(typename01, typename), \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_CAPTURE_TYPE_(id))
#define BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPEDEF_TYPED_( \
- id, all_bind_this_types) \
+ id, typename01, all_bind_this_types) \
typedef \
BOOST_LOCAL_FUNCTION_AUX_PP_BIND_TRAITS_THIS_TYPE(BOOST_PP_LIST_FIRST( \
all_bind_this_types)) \
- BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id) \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_CAPTURE_TYPE_(id) \
;
#define BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPEDEF_( \
- id, all_bind_this_types) \
+ id, typename01, all_bind_this_types) \
/* typedef type_ */ \
BOOST_PP_IIF(BOOST_PP_IS_EMPTY( \
/* all_bind_this_type is list with 1 elem (possibly PP_EMPTY), */ \
@@ -147,7 +148,7 @@
BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPEDEF_DEDUCED_ \
, \
BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPEDEF_TYPED_ \
- )(id, all_bind_this_types)
+ )(id, typename01, all_bind_this_types)
#define BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_ALL_( \
all_binds, all_bind_this_types, id, typename01) \
@@ -155,16 +156,21 @@
BOOST_PP_IIF(BOOST_PP_LIST_IS_CONS(all_bind_this_types), \
BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPEDEF_ \
, \
- BOOST_PP_TUPLE_EAT(2) \
- )(id, all_bind_this_types) \
+ BOOST_PP_TUPLE_EAT(3) \
+ )(id, typename01, all_bind_this_types) \
BOOST_PP_LIST_FOR_EACH_I(BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_TAG_DECL_, id, \
all_binds) \
BOOST_PP_LIST_FOR_EACH_I(BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_CAPTURE_DECL_, \
(id, typename01), all_binds) \
/* binding class */ \
struct BOOST_SCOPE_EXIT_DETAIL_PARAMS_T(id) { \
+ /* interim capture types to workaround internal error on old GCC */ \
BOOST_PP_EXPR_IIF(BOOST_PP_LIST_IS_CONS(all_bind_this_types), \
- BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id) \
+ typedef BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_CAPTURE_TYPE_(id) \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE_(id) ; \
+ ) \
+ BOOST_PP_EXPR_IIF(BOOST_PP_LIST_IS_CONS(all_bind_this_types), \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE_(id) \
BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_VAR; \
) \
BOOST_PP_LIST_FOR_EACH_I( \
@@ -207,8 +213,10 @@
// PUBLIC //
-#define BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id) \
- BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (this_type)(id) )
+#define BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01) \
+ BOOST_PP_EXPR_IIF(typename01, typename) \
+ BOOST_SCOPE_EXIT_DETAIL_PARAMS_T(id):: \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE_(id)
#define BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_VAR \
BOOST_LOCAL_FUNCTION_AUX_SYMBOL( (this_var) )
Modified: trunk/boost/local_function/aux_/macro/code_/functor.hpp
==============================================================================
--- trunk/boost/local_function/aux_/macro/code_/functor.hpp (original)
+++ trunk/boost/local_function/aux_/macro/code_/functor.hpp 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
@@ -237,14 +237,16 @@
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_MAYBECONST_BIND_PARAM_( \
BOOST_PP_TUPLE_ELEM(4, 2, id_typename_offset_const), i)
-#define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_THIS_TYPE_(id) \
- , BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id)
+#define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_THIS_TYPE_( \
+ id, typename01) \
+ , BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01)
#define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_THIS_PARAM_ \
bind_this
-#define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_THIS_PARAM_DECL_(id) \
- , BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id) & \
+#define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_THIS_PARAM_DECL_( \
+ id, typename01) \
+ , BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01) & \
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_THIS_PARAM_
#define BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_NOBIND_(z, n, unused) \
@@ -423,8 +425,8 @@
has_const_bind_this), \
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_THIS_PARAM_DECL_ \
, \
- BOOST_PP_TUPLE_EAT(1) \
- )(id) \
+ BOOST_PP_TUPLE_EAT(2) \
+ )(id, typename01) \
/* fill with nobind_t (if no local-types as tparams) */ \
BOOST_PP_REPEAT(BOOST_PP_SUB(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, \
BOOST_PP_IIF(BOOST_PP_BITOR(has_bind_this, \
@@ -541,8 +543,8 @@
has_const_bind_this), \
BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_COMMA_BIND_THIS_TYPE_ \
, \
- BOOST_PP_TUPLE_EAT(1) \
- )(id) \
+ BOOST_PP_TUPLE_EAT(2) \
+ )(id, typename01) \
/* fill with nobind_t (if no local-types as tparams) */ \
BOOST_PP_REPEAT(BOOST_PP_SUB(BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX, \
BOOST_PP_IIF(BOOST_PP_BITOR(has_bind_this, has_const_bind_this), \
@@ -575,7 +577,7 @@
typedef BOOST_LOCAL_FUNCTION_AUX_TYPEOF_TYPE( \
BOOST_PP_EXPR_IIF(typename01, typename) \
::boost::local_function::aux::add_pointed_const< \
- BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id) \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01) \
>::type \
this_ \
) ; /* close typedef */ \
@@ -583,7 +585,7 @@
/* ... or, non-const this */ \
BOOST_PP_EXPR_IIF(has_bind_this, \
typedef BOOST_LOCAL_FUNCTION_AUX_TYPEOF_TYPE( \
- BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id) \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01) \
this_ \
) ; /* close typedef */ \
)
@@ -605,8 +607,9 @@
/* bind this const or not (pointed-const is not added here because */ \
/* this is a reference, it is added to the this_ body param instead */ \
BOOST_PP_EXPR_IIF(BOOST_PP_BITOR(has_bind_this, has_const_bind_this), \
- BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id)/* this is * so no & */\
- BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_MEMBER_THIS_ \
+ /* this is * so no & */ \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, typename01) \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_FUNCTOR_BIND_MEMBER_THIS_ \
; /* end member variable declaration */ \
)
@@ -823,14 +826,16 @@
BOOST_PP_EXPR_IIF(has_const_bind_this, \
BOOST_PP_EXPR_IIF(typename01, typename) \
::boost::local_function::aux::add_pointed_const< \
- BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id) \
- >::type const \
- this_ /* special name to access object this */ \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, \
+ typename01) \
+ >::type \
+ const this_ /* special name to access object this */ \
) \
/* const pointer to non-const object */ \
BOOST_PP_EXPR_IIF(has_bind_this, \
- BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id) const \
- this_ /* special name to access object this */ \
+ BOOST_LOCAL_FUNCTION_AUX_CODE_BIND_THIS_TYPE(id, \
+ typename01) \
+ const this_ /* special name to access object this */ \
) \
/* params (last because they can have defaults) */ \
BOOST_PP_COMMA_IF( \
Modified: trunk/boost/scope_exit.hpp
==============================================================================
--- trunk/boost/scope_exit.hpp (original)
+++ trunk/boost/scope_exit.hpp 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
@@ -26,6 +26,7 @@
#include <boost/preprocessor/logical/bitor.hpp>
#include <boost/preprocessor/logical/bitand.hpp>
#include <boost/preprocessor/facilities/empty.hpp>
+#include <boost/preprocessor/facilities/is_empty.hpp>
#include <boost/preprocessor/facilities/identity.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/punctuation/paren_if.hpp>
@@ -66,12 +67,6 @@
# define BOOST_SCOPE_EXIT_AUX_TYPEOF_THIS_WORKAROUND_01 0
#endif
-#if !defined(BOOST_NO_LAMBDAS) && !defined(BOOST_SCOPE_EXIT_CONFIG_NO_CPP11)
-# define BOOST_SCOPE_EXIT_AUX_LAMBDAS_01 1
-#else
-# define BOOST_SCOPE_EXIT_AUX_LAMBDAS_01 0
-#endif
-
// Steven Watanabe's trick with a modification suggested by Kim Barrett
namespace boost { namespace scope_exit { namespace detail {
@@ -141,7 +136,7 @@
template<class T> wrapper<T> wrap(T&);
-} } }
+} } } // namespace
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::scope_exit::detail::wrapper, 1)
@@ -149,10 +144,20 @@
#define BOOST_SCOPE_EXIT_AUX_ARGS boost_scope_exit_aux_args
extern boost::scope_exit::detail::undeclared BOOST_SCOPE_EXIT_AUX_ARGS;
-#define BOOST_SCOPE_EXIT_AUX_GUARD(id) BOOST_PP_CAT(boost_se_guard_, id)
-#define BOOST_SCOPE_EXIT_AUX_GUARD_T(id) BOOST_PP_CAT(boost_se_guard_t_, id)
-#define BOOST_SCOPE_EXIT_AUX_PARAMS(id) BOOST_PP_CAT(boost_se_params_, id)
-#define BOOST_SCOPE_EXIT_AUX_THIS_T(id) BOOST_PP_CAT(boost_se_this_t_, id)
+#define BOOST_SCOPE_EXIT_AUX_GUARD(id) \
+ BOOST_PP_CAT(boost_se_guard_, id)
+
+#define BOOST_SCOPE_EXIT_AUX_GUARD_T(id) \
+ BOOST_PP_CAT(boost_se_guard_t_, id)
+
+#define BOOST_SCOPE_EXIT_AUX_PARAMS(id) \
+ BOOST_PP_CAT(boost_se_params_, id)
+
+#define BOOST_SCOPE_EXIT_AUX_THIS_T(id) \
+ BOOST_PP_CAT(boost_se_this_t_, id)
+
+#define BOOST_SCOPE_EXIT_AUX_THIS_CAPTURE_T(id) \
+ BOOST_PP_CAT(boost_se_this_capture_t_, id)
#define BOOST_SCOPE_EXIT_DETAIL_PARAMS_T(id) \
BOOST_PP_CAT(boost_se_params_t_, id)
@@ -258,42 +263,58 @@
boost::type_of::msvc_register_type<T, Organizer> typeof_register_type(const T&,
Organizer* = 0);
-} } } }
+} } } } // namespace
#define BOOST_SCOPE_EXIT_AUX_TYPEDEF_TYPEOF_THIS_INDEX_(id) \
BOOST_PP_CAT(boost_se_thistype_index_, id)
-#define BOOST_SCOPE_EXIT_DETAIL_TYPEDEF_TYPEOF_THIS(id, new_type) \
+#define BOOST_SCOPE_EXIT_DETAIL_TYPEDEF_TYPEOF_THIS(id, ty, new_type) \
enum { \
BOOST_SCOPE_EXIT_AUX_TYPEDEF_TYPEOF_THIS_INDEX_(id) = sizeof( \
*::boost::scope_exit::aux::msvc_typeof_this::encode_start(this)) \
}; \
- typedef ::boost::scope_exit::aux::msvc_typeof_this::msvc_typeid_wrapper< \
+ typedef \
+ ty ::boost::scope_exit::aux::msvc_typeof_this::msvc_typeid_wrapper< \
BOOST_SCOPE_EXIT_AUX_TYPEDEF_TYPEOF_THIS_INDEX_(id) \
- >::type new_type;
+ >::type \
+ new_type \
+ ;
#else // TYPEOF_THIS_WORKAROUND
-#define BOOST_SCOPE_EXIT_DETAIL_TYPEDEF_TYPEOF_THIS(id, new_type) \
- typedef BOOST_TYPEOF(this) new_type;
+#define BOOST_SCOPE_EXIT_DETAIL_TYPEDEF_TYPEOF_THIS(id, ty, new_type) \
+ typedef \
+ BOOST_PP_IIF(BOOST_PP_IS_EMPTY(ty), \
+ BOOST_TYPEOF \
+ , \
+ BOOST_TYPEOF_TPL \
+ )(this) \
+ new_type \
+ ;
#endif // TYPEOF_THIS_WORKAROUND
#if BOOST_SCOPE_EXIT_AUX_TPL_WORKAROUND_01
-#define BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, captures, has_this)
+#define BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, ty, captures, has_this) \
+ /* expand to nothing */
#define BOOST_SCOPE_EXIT_DETAIL_PARAM_INIT(r, id, i, var) \
BOOST_PP_COMMA_IF(i) { BOOST_SCOPE_EXIT_AUX_DEREF(id, i, var) }
#define BOOST_SCOPE_EXIT_AUX_PARAMS_INIT(id, captures, has_this) \
- BOOST_PP_EXPR_IIF(BOOST_PP_LIST_IS_CONS(captures), = { ) \
- BOOST_PP_LIST_FOR_EACH_I(BOOST_SCOPE_EXIT_DETAIL_PARAM_INIT, id, \
- captures) \
- BOOST_PP_COMMA_IF(BOOST_PP_BITAND(BOOST_PP_LIST_IS_CONS(captures), \
- has_this)) \
- BOOST_PP_EXPR_IIF(has_this, this) /* no extra {...} needed here */ \
- BOOST_PP_EXPR_IIF(BOOST_PP_LIST_IS_CONS(captures), } )
+ BOOST_PP_EXPR_IIF(BOOST_PP_BITOR(has_this, \
+ BOOST_PP_LIST_IS_CONS(captures)), \
+ = { \
+ ) \
+ BOOST_PP_LIST_FOR_EACH_I(BOOST_SCOPE_EXIT_DETAIL_PARAM_INIT, id, captures) \
+ BOOST_PP_COMMA_IF(BOOST_PP_BITAND(BOOST_PP_LIST_IS_CONS(captures), \
+ has_this)) \
+ BOOST_PP_EXPR_IIF(has_this, this) /* no extra {...} needed here */ \
+ BOOST_PP_EXPR_IIF(BOOST_PP_BITOR(has_this, \
+ BOOST_PP_LIST_IS_CONS(captures)), \
+ } /* trailing `;` will be added by the caller */ \
+ )
#else
@@ -305,22 +326,27 @@
BOOST_PP_COMMA_IF(i) \
BOOST_SCOPE_EXIT_DETAIL_PARAM(id, i, var) ( BOOST_PP_CAT(a, i) )
-#define BOOST_SCOPE_EXIT_AUX_CTOR_ARG_THIS(id, comma01) \
+#define BOOST_SCOPE_EXIT_AUX_CTOR_ARG_THIS_NAME(id) \
+ BOOST_PP_CAT(boost_se_this_arg_, id)
+
+#define BOOST_SCOPE_EXIT_AUX_CTOR_ARG_THIS(id, ty, comma01) \
BOOST_PP_COMMA_IF(comma01) \
- BOOST_SCOPE_EXIT_AUX_THIS_T(id) /* ptr type so no & */ a_this
+ ty BOOST_SCOPE_EXIT_DETAIL_PARAMS_T(id)::BOOST_SCOPE_EXIT_AUX_THIS_T(id) \
+ BOOST_SCOPE_EXIT_AUX_CTOR_ARG_THIS_NAME(id) /* ptr so no & */
#define BOOST_SCOPE_EXIT_AUX_MEMBER_THIS_INIT(id, comma01) \
BOOST_PP_COMMA_IF(comma01) \
- BOOST_SCOPE_EXIT_DETAIL_PARAM_THIS(id) ( a_this )
+ BOOST_SCOPE_EXIT_DETAIL_PARAM_THIS(id)( \
+ BOOST_SCOPE_EXIT_AUX_CTOR_ARG_THIS_NAME(id))
-#define BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, captures, has_this) \
+#define BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, ty, captures, has_this) \
BOOST_SCOPE_EXIT_DETAIL_PARAMS_T(id)( \
BOOST_PP_LIST_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_CTOR_ARG, id, captures) \
BOOST_PP_IIF(has_this, \
BOOST_SCOPE_EXIT_AUX_CTOR_ARG_THIS \
, \
- BOOST_PP_TUPLE_EAT(2) \
- )(id, BOOST_PP_LIST_IS_CONS(captures)) \
+ BOOST_PP_TUPLE_EAT(3) \
+ )(id, ty, BOOST_PP_LIST_IS_CONS(captures)) \
) \
BOOST_PP_EXPR_IIF(BOOST_PP_BITOR(BOOST_PP_LIST_IS_CONS(captures), \
has_this), \
@@ -438,7 +464,7 @@
#define BOOST_SCOPE_EXIT_AUX_TRAITS_HAS_THIS(traits) \
BOOST_PP_TUPLE_ELEM(2, 1, traits)
-#if BOOST_SCOPE_EXIT_AUX_LAMBDAS_01 // Lambdas.
+#ifndef BOOST_NO_LAMBDAS
namespace boost { namespace scope_exit { namespace aux {
@@ -462,9 +488,9 @@
boost::function<void (void)> f_;
};
-} } }
+} } } // namespace
-#define BOOST_SCOPE_EXIT_AUX_IMPL(id, traits, unused) \
+#define BOOST_SCOPE_EXIT_AUX_IMPL_LAMBDA(id, traits) \
::boost::scope_exit::aux::guard< \
BOOST_PP_IIF(BOOST_SCOPE_EXIT_AUX_TRAITS_HAS_THIS(traits), \
/* no need for TYPEDEF THIS MSVC workaround on C++11 */ \
@@ -489,10 +515,18 @@
BOOST_PP_EXPR_IIF(BOOST_SCOPE_EXIT_AUX_TRAITS_HAS_THIS(traits), this_) \
) mutable -> void
-#else // No lambdas.
+#endif // Lambdas.
+
+#if defined(BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDA_IMPLEMENTATION) && \
+ !defined(BOOST_NO_LAMBDAS) // Use lambda for SCOPE_EXIT (not just _ALL).
+
+#define BOOST_SCOPE_EXIT_AUX_IMPL(id, ty, traits) \
+ BOOST_SCOPE_EXIT_AUX_IMPL_LAMBDA(id, traits)
+
+#else // Not using lambdas.
// ty: EMPTY() | typename
-#define BOOST_SCOPE_EXIT_AUX_IMPL(id, traits, ty) \
+#define BOOST_SCOPE_EXIT_AUX_IMPL(id, ty, traits) \
BOOST_PP_LIST_FOR_EACH_I(BOOST_SCOPE_EXIT_DETAIL_TAG_DECL, id, \
BOOST_SCOPE_EXIT_AUX_TRAITS_CAPTURES(traits)) \
BOOST_PP_LIST_FOR_EACH_I(BOOST_SCOPE_EXIT_DETAIL_CAPTURE_DECL, (id, ty), \
@@ -500,18 +534,23 @@
BOOST_PP_IIF(BOOST_SCOPE_EXIT_AUX_TRAITS_HAS_THIS(traits), \
BOOST_SCOPE_EXIT_DETAIL_TYPEDEF_TYPEOF_THIS \
, \
- BOOST_PP_TUPLE_EAT(2) \
- )(id, BOOST_SCOPE_EXIT_AUX_THIS_T(id)) \
+ BOOST_PP_TUPLE_EAT(3) \
+ )(id, ty, BOOST_SCOPE_EXIT_AUX_THIS_CAPTURE_T(id)) \
struct BOOST_SCOPE_EXIT_DETAIL_PARAMS_T(id) { \
+ /* interim capture types to workaround internal errors on old GCC */ \
BOOST_PP_LIST_FOR_EACH_I(BOOST_SCOPE_EXIT_DETAIL_PARAM_DECL, (id, ty), \
BOOST_SCOPE_EXIT_AUX_TRAITS_CAPTURES(traits)) \
+ BOOST_PP_EXPR_IIF(BOOST_SCOPE_EXIT_AUX_TRAITS_HAS_THIS(traits), \
+ typedef BOOST_SCOPE_EXIT_AUX_THIS_CAPTURE_T(id) \
+ BOOST_SCOPE_EXIT_AUX_THIS_T(id) ; \
+ ) \
BOOST_PP_LIST_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_MEMBER, id, \
BOOST_SCOPE_EXIT_AUX_TRAITS_CAPTURES(traits)) \
BOOST_PP_EXPR_IIF(BOOST_SCOPE_EXIT_AUX_TRAITS_HAS_THIS(traits), \
BOOST_SCOPE_EXIT_AUX_THIS_T(id) \
BOOST_SCOPE_EXIT_DETAIL_PARAM_THIS(id) ; \
) \
- BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, \
+ BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, ty, \
BOOST_SCOPE_EXIT_AUX_TRAITS_CAPTURES(traits), \
BOOST_SCOPE_EXIT_AUX_TRAITS_HAS_THIS(traits)) \
} BOOST_SCOPE_EXIT_AUX_PARAMS(id) \
@@ -551,86 +590,80 @@
BOOST_SCOPE_EXIT_AUX_TRAITS_CAPTURES(traits)), \
BOOST_SCOPE_EXIT_AUX_TRAITS_HAS_THIS(traits))) \
BOOST_PP_EXPR_IIF(BOOST_SCOPE_EXIT_AUX_TRAITS_HAS_THIS(traits), \
- BOOST_SCOPE_EXIT_AUX_THIS_T(id) this_ \
+ ty BOOST_SCOPE_EXIT_DETAIL_PARAMS_T(id):: \
+ BOOST_SCOPE_EXIT_AUX_THIS_T(id) this_ \
) \
)
-#endif // Lambdas.
+#endif // Using lambdas.
// PUBLIC //
#if defined(BOOST_NO_VARIADIC_MACROS) // No variadic macros (sequences only).
+# define BOOST_SCOPE_EXIT_ID(id, within_template, void_or_seq) \
+ BOOST_SCOPE_EXIT_AUX_IMPL(id, \
+ BOOST_PP_EXPR_IIF(within_template, typename), \
+ BOOST_SCOPE_EXIT_AUX_TRAITS( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(void_or_seq)))
# define BOOST_SCOPE_EXIT(void_or_seq) \
- BOOST_SCOPE_EXIT_AUX_IMPL( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER \
- , BOOST_SCOPE_EXIT_AUX_TRAITS( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(void_or_seq)) \
- , BOOST_PP_EMPTY() \
- )
-# if BOOST_SCOPE_EXIT_AUX_TPL_WORKAROUND_01 && \
- !BOOST_SCOPE_EXIT_AUX_LAMBDAS_01
+ BOOST_SCOPE_EXIT_ID(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, 0, \
+ void_or_seq)
+# if BOOST_SCOPE_EXIT_AUX_TPL_WORKAROUND_01
# define BOOST_SCOPE_EXIT_TPL(void_or_seq) \
- BOOST_SCOPE_EXIT_AUX_IMPL( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER \
- , BOOST_SCOPE_EXIT_AUX_TRAITS( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(void_or_seq)) \
- , typename \
- )
-# else // No TPL workaround or lambdas (for backward compatibility).
+ BOOST_SCOPE_EXIT_ID(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, 1,\
+ void_or_seq)
+# else // No TPL workaround.
# define BOOST_SCOPE_EXIT_TPL(void_or_seq) \
BOOST_SCOPE_EXIT(void_or_seq)
# endif
-# if BOOST_SCOPE_EXIT_AUX_LAMBDAS_01 /* C++11 only */
+# if !defined(BOOST_NO_LAMBDAS)
+# define BOOST_SCOPE_EXIT_ALL_ID(id, seq) \
+ BOOST_SCOPE_EXIT_AUX_IMPL_LAMBDA(id, \
+ BOOST_SCOPE_EXIT_AUX_TRAITS_ALL( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_NON_VOID_LIST(seq)))
# define BOOST_SCOPE_EXIT_ALL(seq) \
- BOOST_SCOPE_EXIT_AUX_IMPL( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER \
- , BOOST_SCOPE_EXIT_AUX_TRAITS_ALL( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_NON_VOID_LIST(seq)) \
- , ~ /* unused on C++11 */ \
- )
+ BOOST_SCOPE_EXIT_ALL_ID( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, seq)
# endif
#else // Variadic macros (both sequences and variadic tuples).
+# define BOOST_SCOPE_EXIT_ID(id, within_template, ...) \
+ BOOST_SCOPE_EXIT_AUX_IMPL(id, \
+ BOOST_PP_EXPR_IIF(within_template, typename), \
+ BOOST_SCOPE_EXIT_AUX_TRAITS( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__)))
# define BOOST_SCOPE_EXIT(...) \
- BOOST_SCOPE_EXIT_AUX_IMPL( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER \
- , BOOST_SCOPE_EXIT_AUX_TRAITS( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__)) \
- , BOOST_PP_EMPTY() \
- )
-# if BOOST_SCOPE_EXIT_AUX_TPL_WORKAROUND_01 && \
- !BOOST_SCOPE_EXIT_AUX_LAMBDAS_01
+ BOOST_SCOPE_EXIT_ID(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, 0, \
+ __VA_ARGS__)
+# if BOOST_SCOPE_EXIT_AUX_TPL_WORKAROUND_01
# define BOOST_SCOPE_EXIT_TPL(...) \
- BOOST_SCOPE_EXIT_AUX_IMPL( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER \
- , BOOST_SCOPE_EXIT_AUX_TRAITS( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__)) \
- , typename \
- )
-# else // No TPL workaround or lambdas (for backward compatibility).
+ BOOST_SCOPE_EXIT_ID(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, 1,\
+ __VA_ARGS__)
+# else // No TPL workaround.
# define BOOST_SCOPE_EXIT_TPL(...) \
BOOST_SCOPE_EXIT(__VA_ARGS__)
# endif
-# if BOOST_SCOPE_EXIT_AUX_LAMBDAS_01 /* C++11 only */
+# if !defined(BOOST_NO_LAMBDAS)
+# define BOOST_SCOPE_EXIT_ALL_ID(id, ...) \
+ BOOST_SCOPE_EXIT_AUX_IMPL_LAMBDA(id, \
+ BOOST_SCOPE_EXIT_AUX_TRAITS_ALL( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_NON_VOID_LIST( \
+ __VA_ARGS__)))
# define BOOST_SCOPE_EXIT_ALL(...) \
- BOOST_SCOPE_EXIT_AUX_IMPL( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER \
- , BOOST_SCOPE_EXIT_AUX_TRAITS_ALL( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_NON_VOID_LIST( \
- __VA_ARGS__)) \
- , ~ /* unused on C++11 */ \
- )
+ BOOST_SCOPE_EXIT_ALL_ID( \
+ BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, __VA_ARGS__)
# endif
#endif // Variadics.
-#if BOOST_SCOPE_EXIT_AUX_LAMBDAS_01 // Lambdas.
-# define BOOST_SCOPE_EXIT_END \
- ; /* for backward compatibility */
-#else // No lambdas.
-# define BOOST_SCOPE_EXIT_END \
- } BOOST_SCOPE_EXIT_AUX_GUARD( \
- BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER \
- )(BOOST_SCOPE_EXIT_AUX_ARGS.value);
-#endif // Lambdas.
+#if defined(BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDA_IMPLEMENTATION) && \
+ !defined(BOOST_NO_LAMBDAS) // Use lambdas for SCOPE_EXIT (not just ALL).
+# define BOOST_SCOPE_EXIT_END_ID(id) \
+ ; /* lambdas ended with just `;` */
+#else // Not using lambdas.
+# define BOOST_SCOPE_EXIT_END_ID(id) \
+ } BOOST_SCOPE_EXIT_AUX_GUARD(id)(BOOST_SCOPE_EXIT_AUX_ARGS.value);
+#endif // Using lambdas.
+#define BOOST_SCOPE_EXIT_END \
+ BOOST_SCOPE_EXIT_END_ID(BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER)
// DOCUMENTATION //
@@ -760,6 +793,35 @@
#define BOOST_SCOPE_EXIT_TPL(capture_list)
/**
+@brief This macro allows to expand multiple scope-exits on the same line.
+
+This macro is equivalent to @RefMacro{BOOST_SCOPE_EXIT} but it can be expanded
+multiple times on the same line if different identifiers <c>id</c> are provided
+for each expansion (see @RefMacro{BOOST_SCOPE_EXIT} for more detail).
+
+@Params
+@Param{id,
+ A unique identifier token which can be catted by the preprocessor (for
+ example <c>__LINE__</c> or <c>scope_exit_number_1_on_line_123</c>).
+}
+@Param{within_template,
+ If this macro is used in a type-dependant context on GCC then <c>1</c>
+ (equivalently to @RefMacro{BOOST_SCOPE_EXIT_TPL}), <c>0</c> otherwise.
+}
+@Param{capture_list,
+ Same as the <c>capture_list</c> parameter of the
+ @RefMacro{BOOST_SCOPE_EXIT} macro: <c>void</c>\, or a comma separated
+ list\, or a preprocessor sequence (if no variadic macros) of variables in
+ scope to capture.
+}
+@endParams
+
+@See @RefMacro{BOOST_SCOPE_EXIT_END_ID}, @RefMacro{BOOST_SCOPE_EXIT_ALL_ID},
+ @RefMacro{BOOST_SCOPE_EXIT}, @RefMacro{BOOST_SCOPE_EXIT_TPL}.
+*/
+#define BOOST_SCOPE_EXIT_ID(id, within_template, capture_list)
+
+/**
@brief This macro declares a scope exit that captures all variables in scope (C++11 only).
This macro accepts a capture list starting with either <c>&</c> or <c>=</c> to capture all variables in scope by reference or value respectively (following the same syntax of C++11 lambdas).
@@ -814,6 +876,31 @@
#define BOOST_SCOPE_EXIT_ALL(capture_list)
/**
+@brief This macro allows to expand multiple scope-exits on the same line.
+
+This macro is equivalent to @RefMacro{BOOST_SCOPE_EXIT_ALL} but it can be
+expanded multiple times on the same line if different identifiers <c>id</c> are
+provided for each expansion (see @RefMacro{BOOST_SCOPE_EXIT_ALL} for more
+detail).
+
+@Params
+@Param{id,
+ A unique identifier token which can be catted by the preprocessor (for
+ example <c>__LINE__</c> or <c>scope_exit_number_1_on_line_123</c>).
+}
+@Param{capture_list,
+ Same as the <c>capture_list</c> parameter of the
+ @RefMacro{BOOST_SCOPE_EXIT} macro: <c>void</c>\, or a comma separated
+ list\, or a preprocessor sequence (if no variadic macros) of variables in
+ scope to capture.
+}
+@endParams
+
+@See @RefMacro{BOOST_SCOPE_EXIT_ID}, @RefMacro{BOOST_SCOPE_EXIT_ALL}.
+*/
+#define BOOST_SCOPE_EXIT_ALL_ID(id, capture_list)
+
+/**
@brief This macro marks the end of a scope exit body.
This macro must follow the closing curly bracket <c>}</c> that ends the scope exit body:
@@ -845,16 +932,40 @@
#define BOOST_SCOPE_EXIT_END
/**
-_at_brief Force not to use C++11 features.
+@brief This macro allows to expand multiple scope-exits on the same line.
+
+This macro is equivalent to @RefMacro{BOOST_SCOPE_EXIT_END} but it can be
+expanded multiple times on the same line if different identifiers <c>id</c> are
+provided for each expansion (see @RefMacro{BOOST_SCOPE_EXIT_END} for more
+detail).
-If programmers define this configuration macro, C++11 features will not be used even on C++11 compilers (only C++03 features will be used).
+@Params
+@Param{id,
+ A unique identifier token which can be catted by the preprocessor (for
+ example <c>__LINE__</c> or <c>scope_exit_number_1_on_line_123</c>).
+}
+@endParams
+
+@See @RefMacro{BOOST_SCOPE_EXIT_ID}, @RefMacro{BOOST_SCOPE_EXIT_END}.
+*/
+#define BOOST_SCOPE_EXIT_END_ID(id)
+
+/**
+@brief Force to use C++11 lambda implementation for scope-exit macro.
+
+If programmers define this configuration macro on a C++11 compiler, lambda functions will be used to implement the @RefMacro{BOOST_SCOPE_EXIT} macro.
By default this macro is not defined.
-_at_Note This macro does not disable comma-separated capture lists on compilers that support variadic macros (programmers can simply use Boost.Preprocessor sequences if they do not wish to use comma-separated capture lists).
+@Note When @RefMacro{BOOST_SCOPE_EXIT} is implemented using lambda, the semantics of its variable captures follow the semantics of C++11 lambda captures which are in general different from the legacy capture semantics of this library (e.g., C++11 lambdas require to capture data members via capturing the object <c>this</c> while this library always allowed to capture data members directly).
+Therefore, when this configuration macro is defined, @RefMacro{BOOST_SCOPE_EXIT} is no longer backward compatible.
+
+A semicolon <c>;</c> can simply be used instead of @RefMacro{BOOST_SCOPE_EXIT_END} when this configuration macro is defined.
+
+This configuration macro does not control the definition of @RefMacro{BOOST_SCOPE_EXIT_ALL} which is always and automatically defined on compilers that support C++11 lambdas.
@See @RefMacro{BOOST_SCOPE_EXIT}, @RefMacro{BOOST_SCOPE_EXIT_ALL}, @RefMacro{BOOST_SCOPE_EXIT_END}.
*/
-#define BOOST_SCOPE_EXIT_CONFIG_NO_CPP11
+#define BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDA_IMPLEMENTATION
#endif // DOXYGEN
Modified: trunk/libs/scope_exit/test/Jamfile.v2
==============================================================================
--- trunk/libs/scope_exit/test/Jamfile.v2 (original)
+++ trunk/libs/scope_exit/test/Jamfile.v2 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
@@ -38,6 +38,7 @@
: [ run native.cpp : : : <define>BOOST_TYPEOF_NATIVE ]
[ run native_tpl.cpp : : : <define>BOOST_TYPEOF_NATIVE ]
[ run native_this.cpp : : : <define>BOOST_TYPEOF_NATIVE ]
+ [ run native_this_tpl.cpp : : : <define>BOOST_TYPEOF_NATIVE ]
[ compile-fail native_const_error.cpp : <define>BOOST_TYPEOF_NATIVE ]
[ compile-fail native_cv_error.cpp : <define>BOOST_TYPEOF_NATIVE ]
# Following test is known to fail on MSVC 7.1 and 8.0.
@@ -51,6 +52,8 @@
emulation_tpl : ]
[ run native_this.cpp : : : <define>BOOST_TYPEOF_EMULATION :
emulation_this : ]
+ [ run native_this_tpl.cpp : : : <define>BOOST_TYPEOF_EMULATION :
+ emulation_this_tpl : ]
[ compile-fail native_const_error.cpp : <define>BOOST_TYPEOF_EMULATION :
emulation_const_error : ]
[ compile-fail native_cv_error.cpp : <define>BOOST_TYPEOF_EMULATION :
Modified: trunk/libs/scope_exit/test/native_this.cpp
==============================================================================
--- trunk/libs/scope_exit/test/native_this.cpp (original)
+++ trunk/libs/scope_exit/test/native_this.cpp 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
@@ -14,21 +14,25 @@
using namespace boost::unit_test;
struct this_tester;
-BOOST_TYPEOF_REGISTER_TYPE(this_tester) // Register before capture of `this_`.
+BOOST_TYPEOF_REGISTER_TYPE(this_tester) // Register before `this_` capture.
struct this_tester {
void check(void) {
- int target;
- BOOST_SCOPE_EXIT( (&target) (this_) ) {
- BOOST_CHECK( this_->value_ == target );
+ value_ = -1;
+
+ BOOST_SCOPE_EXIT( (this_) ) {
+ BOOST_CHECK(this_->value_ == 0);
} BOOST_SCOPE_EXIT_END
+
#if !defined(BOOST_NO_LAMBDAS) && !defined(BOOST_SCOPE_EXIT_CONFIG_NO_CPP11)
BOOST_SCOPE_EXIT_ALL(&, this) {
- BOOST_CHECK( this->value_ == target );
+ BOOST_CHECK(this->value_ == 0);
};
#endif
- value_ = target = 3;
+
+ value_ = 0;
}
+
private:
int value_;
};
Added: trunk/libs/scope_exit/test/native_this_tpl.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/scope_exit/test/native_this_tpl.cpp 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
@@ -0,0 +1,49 @@
+
+// Copyright (C) 2006-2009, 2012 Alexander Nasonov
+// Copyright (C) 2012 Lorenzo Caminiti
+// Distributed under the Boost Software License, Version 1.0
+// (see accompanying file LICENSE_1_0.txt or a copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+// Home at http://www.boost.org/libs/scope_exit
+
+#include <boost/scope_exit.hpp>
+#include <boost/typeof/typeof.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#include <boost/test/unit_test.hpp>
+
+using namespace boost::unit_test;
+
+template<typename T>
+struct this_tester;
+BOOST_TYPEOF_REGISTER_TEMPLATE(this_tester, 1) // Before`this_` capture.
+
+template<typename T>
+struct this_tester {
+ void check(void) {
+ value_ = -1;
+
+ BOOST_SCOPE_EXIT_TPL( (this_) ) {
+ BOOST_CHECK(this_->value_ == 0);
+ } BOOST_SCOPE_EXIT_END
+
+#if !defined(BOOST_NO_LAMBDAS) && !defined(BOOST_SCOPE_EXIT_CONFIG_NO_CPP11)
+ BOOST_SCOPE_EXIT_ALL(&, this) {
+ BOOST_CHECK(this->value_ == 0);
+ };
+#endif
+
+ value_ = 0;
+ }
+
+private:
+ T value_;
+};
+
+void test_this_tpl(void) { this_tester<int>().check(); }
+
+test_suite* init_unit_test_suite(int, char* []) {
+ framework::master_test_suite().p_name.value = "Unit test for ScopeExit";
+ framework::master_test_suite().add(BOOST_TEST_CASE(&test_this_tpl));
+ return 0;
+}
+
Modified: trunk/libs/scope_exit/test/world_checkpoint_all.cpp
==============================================================================
--- trunk/libs/scope_exit/test/world_checkpoint_all.cpp (original)
+++ trunk/libs/scope_exit/test/world_checkpoint_all.cpp 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
@@ -62,7 +62,7 @@
person::evolution_t checkpoint = p.evolution;
BOOST_SCOPE_EXIT_ALL(&, checkpoint, this_) { // Capture all by ref (C++11).
if(checkpoint == p.evolution) this_->persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
+ }; // Use `;` instead of `SCOPE_EXIT_END` for `BOOST_SCOPE_EXIT_ALL`.
// ...
@@ -76,7 +76,7 @@
this->next_id_ = p.id;
p.id = prev_id;
}
- }; // Use `;` instead of `SCOPE_EXIT_END` (C++11).
+ };
// ...
Modified: trunk/libs/scope_exit/test/world_checkpoint_all_seq.cpp
==============================================================================
--- trunk/libs/scope_exit/test/world_checkpoint_all_seq.cpp (original)
+++ trunk/libs/scope_exit/test/world_checkpoint_all_seq.cpp 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
@@ -61,7 +61,7 @@
person::evolution_t checkpoint = p.evolution;
BOOST_SCOPE_EXIT_ALL( (&) (checkpoint) (this_) ) {
if(checkpoint == p.evolution) this_->persons_.pop_back();
- } BOOST_SCOPE_EXIT_END
+ };
// ...
@@ -75,7 +75,7 @@
this->next_id_ = p.id;
p.id = prev_id;
}
- }; // Use `;` instead of `SCOPE_EXIT_END` (C++11).
+ };
// ...
Modified: trunk/libs/scope_exit/test/world_this.cpp
==============================================================================
--- trunk/libs/scope_exit/test/world_this.cpp (original)
+++ trunk/libs/scope_exit/test/world_this.cpp 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
@@ -34,19 +34,11 @@
bool commit = false;
persons_.push_back(a_person);
-#ifdef BOOST_NO_LAMBDAS
//[world_this_
BOOST_SCOPE_EXIT(&commit, this_) { // Capture object `this_`.
if(!commit) this_->persons_.pop_back();
} BOOST_SCOPE_EXIT_END
//]
-#else
- //[world_this
- BOOST_SCOPE_EXIT(&commit, this) { // Use `this` (C++11).
- if(!commit) this->persons_.pop_back();
- }; // Use `;` instead of `BOOST_SCOPE_EXIT_END` (C++11).
- //]
-#endif
// ...
Modified: trunk/libs/scope_exit/test/world_this_seq.cpp
==============================================================================
--- trunk/libs/scope_exit/test/world_this_seq.cpp (original)
+++ trunk/libs/scope_exit/test/world_this_seq.cpp 2012-03-18 17:53:39 EDT (Sun, 18 Mar 2012)
@@ -31,15 +31,9 @@
bool commit = false;
persons_.push_back(a_person);
-#ifdef BOOST_NO_LAMBDAS
BOOST_SCOPE_EXIT( (&commit) (this_) ) {
if(!commit) this_->persons_.pop_back();
} BOOST_SCOPE_EXIT_END
-#else
- BOOST_SCOPE_EXIT( (&commit) (this) ) {
- if(!commit) this->persons_.pop_back();
- };
-#endif
// ...
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk