Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Kim Barrett (kab.conundrums_at_[hidden])
Date: 2012-01-25 19:39:36
On Jan 25, 2012, at 6:20 PM, Simonson, Lucanus J wrote:
> I don't personally think that the style of programming that optional is intended for is suitable for high performance/performance critical situations in the first place. Pass by reference and return a bool for a conditional return value. Pass the bool and the object separately for a conditional argument. Pass or return a pointer and check if it is null. Yes, my advice really is to not use optional if you want performance.
All of the offered suggestions require the caller to construct an initial object that can be passed (by reference / pointer) to the callee for replacement. That may be either inefficient (object is expensive to construct) or impossible (caller doesn't have access to an appropriate constructor).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk