Boost logo

Boost :

From: Shunsuke Sogame (mb2act_at_[hidden])
Date: 2006-04-28 14:31:50


Eric Niebler wrote:
> Shunsuke Sogame wrote:
>
>>Hi gurus,
>>
>>VC++7.1/8 complains:
>>
>> error C2355: 'this' : can only be referenced inside non-static member
>>
>>about:
>>
>> struct xxx : std::vector<int>
>> {
>> void test()
>> {
>> BOOST_FOREACH(int x, *this) {
>> }
>> }
>> };
>>
>>GCC compiles.
>>Is this maybe a bug of VC++?
>
> Looks like it. I can't think of a work-around. :-(

I just wanted to know whether it is legal or a bug.
That is somewhat problematic if
'xxx' doesn't know the base range type.
I note user workaround:

     struct xxx : std::vector<int>
     {
         void test()
         {
             foreach(*this);
         }

         template< class SelfT >
         void foreach(SelfT& self)
         {
             BOOST_FOREACH (int x, self) {
             }
         }
     };

Thanks!

-- 
Shunsuke Sogame

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk