|
Boost : |
Subject: Re: [boost] [scope_exit] MSVC error C2355: 'this' : can only be referenced inside non-static member functions
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2010-08-25 20:04:42
[Lorenzo Caminiti]
> I get this error on MSVC 2008 but the code compiles just fine on GCC:
> Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86
That's not 2008, it's 2005 (and it's 2005 RTM).
_MSC_VER == 1400, VC8, VS 2005
_MSC_VER == 1500, VC9, VS 2008
_MSC_VER == 1600, VC10, VS 2010
(Our C++ compiler predates *Visual* C++.)
This compiles with VC10 and Boost 1.44.0:
C:\Temp>type meow.cpp
#include <boost/scope_exit.hpp>
struct c {
void f() {
typedef void (*this_t)(int this_ );
#if defined(BOOST_MSVC) // for MSVC
typedef boost::type_of::msvc_typeid_wrapper<
sizeof(*boost::type_of::encode_start(
#else // for GCC
typedef __typeof__(
boost::type_of::ensure_obj(
#endif
boost::scope_exit::aux::wrap(
boost::scope_exit::aux::deref(
this, (this_t)0
)
)
)
#if defined(BOOST_MSVC) // for MSVC
)>::type
#else // for GCC
)
#endif
this_w;
}
};
int main() {
c cc;
cc.f();
return 0;
}
C:\Temp>cl /EHsc /nologo /W4 /I . meow.cpp
meow.cpp
using native typeof
C:\Temp>meow
C:\Temp>
Stephan T. Lavavej
Visual C++ Libraries Developer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk