Boost logo

Boost :

Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Kim Barrett (kab.conundrums_at_[hidden])
Date: 2012-01-30 16:29:20


On Jan 30, 2012, at 3:49 PM, Simonson, Lucanus J wrote:
> I like pass by reference and return a bool over returning an optional for performance because we allocate memory for the result of the function outside of the function call and there is no transfer of ownership of the result.

Personally, I like returning values rather than modifying arguments. But more importantly, the caller might not even be able to construct that object to be passed by reference, due to lack of access to an appropriate combination of constructor and initialization arguments, such as when the class has no default constructor.

> Even with move semantics, you have just changed an unnecessary copy into cheaper unnecessary move.

If one cares about performance and one's compiler is not capable of doing RVO for optionals, perhaps one should be looking for a better compiler, and not just for better handling of optionals.


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