|
Boost : |
Subject: Re: [boost] [SCOPE_EXIT] compiler errors for structure members
From: Sid Sacek (ssacek_at_[hidden])
Date: 2009-04-20 11:31:21
>> struct {
>> int one;
>> } test ;
>> test.one = 55;
>>
>> BOOST_SCOPE_EXIT( ( test.one ) )
>> {
>> }
>> BOOST_SCOPE_EXIT_END
>>
>> The above code gives me lots of compiler errors. Is there a special
>> syntax I have to provide to be able to use structure members?
>>
>
>This is not supported because only identifiers are allowed. If test was
>a variable of non-local non-anonymous struct type, you could pass it:
>
>BOOST_SCOPE_EXIT( (test ) ) { int one = test.one; ... } BOOST_SCOPE_EXIT_END
>
>Alex
Thank you, Alex. But unfortunately I couldn't use your suggested syntax because the copy-constructor for the structure is being called ( a couple of times. ) Instead, I'm opting for:
struct ttt {
int one;
} test ;
test.one = 55;
int *one_ref = &test.one;
BOOST_SCOPE_EXIT( ( one_ref ) )
{
*one_ref = 666; // experimental code
}
BOOST_SCOPE_EXIT_END;
This solves my problem. What really surprised me however was that when I made 'one_ref' an int&, the original test.one variable never got modified. Some other ( I assume temp variable ) was modified. If you're wondering what this is about, I'm trying to create a new macro that uses your macro.
Regards,
-Sid Sacek
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk