Boost logo

Boost :

From: Darren Cook (darren_at_[hidden])
Date: 2004-07-07 19:12:25


>>I'm not sure which of a/b/c I am, but if I saw the below code I would be
>>surprised if foo() was not evaluated before bar(). If it was a function:
>> f( foo(), bar() );
>>would foo() always be executed before bar()?
>
> No. This is a common misconception and a common source of bugs that only show up
> when optimizations are turned on. It's also a source of exception-unsafe code,
> as detailed in Exceptional C++ and a GOTW column.

That kind of validates using v+=foo(),bar(); then, but also says why you
shouldn't use it: a common source of bugs.

I think with an initialization library in particular people will write, and
expect to always work, something like:
    v+= get(), get(), get();

Darren


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