
Ami Ganguli wrote:
I came across an interesting problem:
what.let(_placeholder = this);
fails to compile, because 'this' is a const pointer.
A simple workaround:
MyClass *_this = this; what.let(_placeholder = _this);
But surely this shouldn't be necessary? Couldn't the right hand side of the let be declared const?
Interesting! Yes, the placeholder code in xpressive seems to assume that the rhs of the let expression is a non-const lvalue. That's certainly not the case for "this". But even code as simple as this fails to compile: placeholder<int> _i; smatch what; what.let(_i = 1); I'm not quite sure how to handle this at the moment. What should happen with actions like "[ _i += 1 ]" if "_i" ends up bound to something that isn't a mutable lvalue? It's possible that we need a way to specify a placeholder for non-mutable data. Maybe this: placeholder<int const> _i; ... and now an action like "[ _i += 1 ]" can be made to fail at compile time. You should open a ticket for this: http://svn.boost.org. Thanks. -- Eric Niebler BoostPro Computing http://www.boostpro.com