--- boost_1_41_0/boost/scope_exit.hpp 2009-09-08 21:29:10.000000000 +0100 +++ boost_1_41_0/boost/scope_exit.hpp 2009-11-24 15:27:22.000000000 +0000 @@ -16,6 +16,7 @@ #include #include #include +#include #include #if defined(__GNUC__) && !defined(BOOST_INTEL) @@ -150,15 +151,156 @@ typedef void (*BOOST_SCOPE_EXIT_AUX_TAG(id,i))(int var); +//----begin-'this-capture'-detection-and-selection-mechanics---- + +#if BOOST_WORKAROUND(BOOST_MSVC,>=1300) + // Boost.Typeof for VC71's typeid-based workaround does not work + // to determine the type of 'this' due to error C2355 being + // incorrectly reported (a compiler bug that's present in 8 and 9 + // also). The typical avoidance strategy to evade this error is + // to make an indirect compile-time constant by assignment through + // enum, then use that as a type-index. This cannot happen with + // the typeid() approach, only with a sizeof() approach. + // + // The implementation below is the more general, type-index + // sizeof()-based approach implemented in Boost.Typeof which + // appears to work fine for typeof(this) provided the reference to + // 'this' is not present in the template argument list (i.e. the + // type-index is captured into a local enumerator before being + // used as a template argument). + // + // Inline documentation is removed and conditional compilation + // applied. + // + namespace boost { namespace scope_exit { namespace msvc_typeof_this + { + template + struct msvc_typeid_wrapper { + typedef typename boost::type_of::msvc_extract_type >::id2type id2type; + typedef typename id2type::type type; + }; + template<> + struct msvc_typeid_wrapper<4> { + typedef msvc_typeid_wrapper<4> type; + }; + template + struct encode_type + { + BOOST_STATIC_CONSTANT(unsigned,value=BOOST_TYPEOF_INDEX(T)); + typedef typename boost::type_of::msvc_register_type >::id2type type; + BOOST_STATIC_CONSTANT(unsigned,next=value+1); + BOOST_TYPEOF_NEXT_INDEX(next); + }; + template + struct sizer + { + typedef char(*type)[encode_type::value]; + }; + template typename disable_if< + typename is_function::type, + typename sizer::type>::type encode_start(T const&); + template typename enable_if< + typename is_function::type, + typename sizer::type>::type encode_start(T&); + template + boost::type_of::msvc_register_type typeof_register_type(const T&,Organizer* =0); + + }}} + +# define BOOST_SCOPE_EXIT_TYPEDEF_TYPEOF_THIS() \ + enum { BOOST_PP_CAT(boost_se_thistype_index_,__LINE__) = sizeof(*boost::scope_exit::msvc_typeof_this::encode_start(this)) }; \ + typedef boost::scope_exit::msvc_typeof_this::msvc_typeid_wrapper::type + +#else // other Boost.Typeof 'this' appear to be okay +# define BOOST_SCOPE_EXIT_TYPEDEF_TYPEOF_THIS() typedef BOOST_TYPEOF(this) +#endif + +// 'this-capture' function-macros for when (*this) is requested +// +#define BOOST_SCOPE_EXIT_REALTHIS_COMMA_IF_this(seq) this BOOST_PP_COMMA_IF(BOOST_PP_SEQ_SIZE(seq)) +#define BOOST_SCOPE_EXIT_THISPARAM_COMMA_IF_this(id,seq) BOOST_PP_CAT(se_this_type,id) se_this BOOST_PP_COMMA_IF(BOOST_PP_SEQ_SIZE(seq)) +#define BOOST_SCOPE_EXIT_THISINIT_COMMA_IF_this(seq) se_this(se_this) BOOST_PP_COMMA_IF(BOOST_PP_SEQ_SIZE(seq)) +#define BOOST_SCOPE_EXIT_THISINIT_BEGIN_PARAM_T_INITLIST_this(seq) : +#define BOOST_SCOPE_EXIT_HASARGS_this(seq) 1 + +#define BOOST_SCOPE_EXIT_TYPEDEF_THISTYPE_this(id) BOOST_SCOPE_EXIT_TYPEDEF_TYPEOF_THIS() BOOST_PP_CAT(se_this_type,id); +#define BOOST_SCOPE_EXIT_DEFINE_THISMEMBER_this(id) BOOST_PP_CAT(se_this_type,id) se_this; +#define BOOST_SCOPE_EXIT_DEFINE_THIS_ACCESSOR_this(id) \ + inline BOOST_PP_CAT(se_this_type,id) operator->() { return boost_se_params_->se_this; } \ + inline BOOST_PP_CAT(se_this_type,id) operator*() { return boost_se_params_->se_this; } \ + inline operator BOOST_PP_CAT(se_this_type,id)() { return boost_se_params_->se_this; } \ + +// 'this-capture' function-macros for when (*this) is not requested +// +#define BOOST_SCOPE_EXIT_REALTHIS_COMMA_IF_nothis(seq) +#define BOOST_SCOPE_EXIT_THISPARAM_COMMA_IF_nothis(id,seq) +#define BOOST_SCOPE_EXIT_THISINIT_COMMA_IF_nothis(seq) +#define BOOST_SCOPE_EXIT_THISINIT_BEGIN_PARAM_T_INITLIST_nothis(seq) BOOST_PP_IF(BOOST_PP_SEQ_SIZE(seq),BOOST_PP_IDENTITY(:),BOOST_PP_EMPTY)() +#define BOOST_SCOPE_EXIT_HASARGS_nothis(seq) BOOST_PP_SEQ_SIZE(seq) + +#define BOOST_SCOPE_EXIT_TYPEDEF_THISTYPE_nothis(id) +#define BOOST_SCOPE_EXIT_DEFINE_THISMEMBER_nothis(id) +#define BOOST_SCOPE_EXIT_DEFINE_THIS_ACCESSOR_nothis(id) + +// Expand to 1 if the first sequence element is 'this' +// or 0 otherwise. +// +// Mechanics: [given that 'this(x)' --> '(this(x))'] +// +// head = front(seq) --> 'this' or 'somearg' +// funcexp = head(_) --> '(this(_))' or 'somearg(_)' +// size_and_possible_tokens = seq_size(funcexp) +// yields either +// 0 somearg(_) +// or 1 +// expansion of 'cat(X,size_and_possible_tokens _) )' +// yields either +// X0 _ ) --> zero( _ ) --> 0 +// or X1 tokens _ ) --> one( tokens _ ) --> 1 +// +// where X0 is BOOST_SCOPE_EXIT_HAS_THIS_CONSUME_0 +// X1 is BOOST_SCOPE_EXIT_HAS_THIS_CONSUME_1 +// zero() is BOOST_SCOPE_EXIT_HAS_THIS_FALSE() +// one() is BOOST_SCOPE_EXIT_HAS_THIS_TRUE() +// +#define BOOST_SCOPE_EXIT_HAS_THIS(seq) \ + BOOST_PP_CAT(BOOST_SCOPE_EXIT_HAS_THIS_CONSUME_, \ + BOOST_PP_SEQ_SIZE(BOOST_PP_SEQ_HEAD(seq)(_)) _) ) \ + +#define BOOST_SCOPE_EXIT_HAS_THIS_CONSUME_0 BOOST_SCOPE_EXIT_HAS_THIS_FALSE( +#define BOOST_SCOPE_EXIT_HAS_THIS_CONSUME_1 BOOST_SCOPE_EXIT_HAS_THIS_TRUE( + +#define BOOST_SCOPE_EXIT_HAS_THIS_FALSE(x) 0 +#define BOOST_SCOPE_EXIT_HAS_THIS_TRUE(x) 1 + +// Form a singleton pre-processor sequence from 'this(...)'. This +// should be innocuous as C++ syntax doesn't permit 'this(...)'. +// Make it equivalent anyway so as to generate appropriate error if +// does happen to be used. +#define this(x) (this(x)) + +// Forwarding front-end to determine whether 'this' is the first +// element of the sequence and adapt the invocation of the detail +// accordingly. The dummy is passed to allow for an empty sequence. +#define BOOST_SCOPE_EXIT_AUX_IMPL_FE(id, seq, ty) \ + BOOST_SCOPE_EXIT_AUX_IMPL_FE2(id, seq, ty, BOOST_SCOPE_EXIT_HAS_THIS(seq (dummy))) \ + +#define BOOST_SCOPE_EXIT_AUX_IMPL_FE2(id, seq, ty, has_this) \ + BOOST_SCOPE_EXIT_AUX_IMPL(id, BOOST_PP_IF(has_this, BOOST_PP_SEQ_TAIL(seq),seq), \ + ty, BOOST_PP_IF(has_this, this,nothis) ) \ + +//----end-'this-capture'-detection-and-selection-mechanics---- + #ifdef BOOST_SCOPE_EXIT_AUX_TPL_WORKAROUND -#define BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, seq) +#define BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, seq, this) #define BOOST_SCOPE_EXIT_AUX_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, seq) \ - = { BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_PARAM_INIT, id, seq) }; +#define BOOST_SCOPE_EXIT_AUX_PARAMS_INIT(id, seq, this) \ + = { BOOST_PP_CAT(BOOST_SCOPE_EXIT_REALTHIS_COMMA_IF_,this)(seq) \ + BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_PARAM_INIT, id, seq) }; #else @@ -168,16 +310,23 @@ #define BOOST_SCOPE_EXIT_AUX_MEMBER_INIT(r, id, i, var) BOOST_PP_COMMA_IF(i) \ BOOST_SCOPE_EXIT_AUX_PARAM(id,i,var) ( BOOST_PP_CAT(a,i) ) -#define BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, seq) \ +#define BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, seq, this) \ BOOST_SCOPE_EXIT_AUX_PARAMS_T(id)( \ + BOOST_PP_CAT(BOOST_SCOPE_EXIT_THISPARAM_COMMA_IF_,this)(id,seq) \ BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_CTOR_ARG, id, seq ) ) \ - : BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_MEMBER_INIT, id, seq) {} + BOOST_PP_CAT(BOOST_SCOPE_EXIT_THISINIT_BEGIN_PARAM_T_INITLIST_,this)(seq)\ + BOOST_PP_CAT(BOOST_SCOPE_EXIT_THISINIT_COMMA_IF_,this)(seq) \ + BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_MEMBER_INIT, id, seq) {} #define BOOST_SCOPE_EXIT_AUX_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, seq) \ - ( BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_PARAM_INIT, id, seq) ); +#define BOOST_SCOPE_EXIT_AUX_PARAMS_INIT(id, seq, this) \ + BOOST_PP_IF(BOOST_PP_CAT(BOOST_SCOPE_EXIT_HASARGS_,this)(seq), \ + BOOST_PP_IDENTITY( \ + ( BOOST_PP_CAT(BOOST_SCOPE_EXIT_REALTHIS_COMMA_IF_,this)(seq) \ + BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_PARAM_INIT, id, seq) ) \ + ),BOOST_PP_EMPTY)(); \ #endif @@ -216,14 +365,16 @@ BOOST_SCOPE_EXIT_AUX_PARAM_T(BOOST_PP_TUPLE_ELEM(2,0,idty), i, var); -#define BOOST_SCOPE_EXIT_AUX_IMPL(id, seq, ty) \ +#define BOOST_SCOPE_EXIT_AUX_IMPL(id, seq, ty, this) \ BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_TAG_DECL, id, seq) \ BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_CAPTURE_DECL, (id,ty), seq) \ + BOOST_PP_CAT(BOOST_SCOPE_EXIT_TYPEDEF_THISTYPE_,this)(id) \ struct BOOST_SCOPE_EXIT_AUX_PARAMS_T(id) { \ + BOOST_PP_CAT(BOOST_SCOPE_EXIT_DEFINE_THISMEMBER_,this)(id) \ BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_PARAM_DECL, (id,ty), seq) \ BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_MEMBER, id, seq) \ - BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, seq) \ - } BOOST_SCOPE_EXIT_AUX_PARAMS(id) BOOST_SCOPE_EXIT_AUX_PARAMS_INIT(id,seq) \ + BOOST_SCOPE_EXIT_AUX_PARAMS_T_CTOR(id, seq, this) \ + } BOOST_SCOPE_EXIT_AUX_PARAMS(id) BOOST_SCOPE_EXIT_AUX_PARAMS_INIT(id, seq, this)\ boost::scope_exit::aux::declared< boost::scope_exit::aux::resolve< \ sizeof(boost_scope_exit_args)>::cmp1<0>::cmp2 > boost_scope_exit_args; \ boost_scope_exit_args.value = &BOOST_SCOPE_EXIT_AUX_PARAMS(id); \ @@ -233,18 +384,23 @@ : boost_se_params_( \ (BOOST_SCOPE_EXIT_AUX_PARAMS_T(id)*)boost_se_params) \ {} \ + BOOST_PP_CAT(BOOST_SCOPE_EXIT_DEFINE_THIS_ACCESSOR_,this)(id) \ ~BOOST_SCOPE_EXIT_AUX_GUARD_T(id)() { boost_se_body( \ BOOST_PP_SEQ_FOR_EACH_I(BOOST_SCOPE_EXIT_AUX_ARG, id, seq) ); } \ - static void boost_se_body(BOOST_PP_SEQ_FOR_EACH_I( \ + void boost_se_body(BOOST_PP_SEQ_FOR_EACH_I( \ BOOST_SCOPE_EXIT_AUX_ARG_DECL, (id,ty), seq) ) #if defined(BOOST_MSVC) +#ifndef BOOST_SCOPE_EXIT_DONT_DISABLE_C4003 +#pragma warning(disable:4003) +#endif + #define BOOST_SCOPE_EXIT_END } BOOST_SCOPE_EXIT_AUX_GUARD(__COUNTER__) ( \ boost_scope_exit_args.value); #define BOOST_SCOPE_EXIT(seq) \ - BOOST_SCOPE_EXIT_AUX_IMPL(__COUNTER__, seq, BOOST_PP_EMPTY()) + BOOST_SCOPE_EXIT_AUX_IMPL_FE(__COUNTER__, seq, BOOST_PP_EMPTY()) #else @@ -252,13 +408,13 @@ boost_scope_exit_args.value); #define BOOST_SCOPE_EXIT(seq) \ - BOOST_SCOPE_EXIT_AUX_IMPL(__LINE__, seq, BOOST_PP_EMPTY()) + BOOST_SCOPE_EXIT_AUX_IMPL_FE(__LINE__, seq, BOOST_PP_EMPTY()) #endif #ifdef BOOST_SCOPE_EXIT_AUX_TPL_WORKAROUND #define BOOST_SCOPE_EXIT_TPL(seq) \ - BOOST_SCOPE_EXIT_AUX_IMPL(__LINE__, seq, typename) + BOOST_SCOPE_EXIT_AUX_IMPL_FE(__LINE__, seq, typename) #else #define BOOST_SCOPE_EXIT_TPL(seq) BOOST_SCOPE_EXIT(seq) #endif --- boost_1_38_0/boost/typeof/msvc/typeof_impl.hpp Fri Feb 27 08:06:09 2009 +++ boost_1_38_0/boost/typeof/msvc/typeof_impl.hpp Fri Feb 27 08:06:51 2009 @@ -70,7 +70,7 @@ } }; -# define BOOST_TYPEOF_INDEX(T) (encode_counter::count) +# define BOOST_TYPEOF_INDEX(T) (boost::type_of::encode_counter::count) # define BOOST_TYPEOF_NEXT_INDEX(next) # else template struct encode_counter : encode_counter {}; @@ -80,7 +80,7 @@ char (*encode_index(...))[5]; # define BOOST_TYPEOF_INDEX(T) (sizeof(*boost::type_of::encode_index((boost::type_of::encode_counter<1005>*)0))) -# define BOOST_TYPEOF_NEXT_INDEX(next) friend char (*encode_index(encode_counter*))[next]; +# define BOOST_TYPEOF_NEXT_INDEX(next) friend char (*boost::type_of::encode_index(encode_counter*))[next]; # endif //Typeof code