Boost logo

Boost :

Subject: Re: [boost] [SCOPE_EXIT] compiler errors for structure members
From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2009-04-20 11:31:48


Sid Sacek <ssacek <at> securewatch24.com> writes:
> 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

Try passing one_ref by reference:

BOOST_SCOPE_EXIT( (&one_ref ) )
// ^ <=========== HERE

Alex


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