Subject: Re: [boost] expected/result/etc
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2016-01-29 08:27:02
On 28 Jan 2016 at 10:32, Michael Marcin wrote:
> If you are going to handle the error in non-generic code very close to
> the caller, I contend there is no need to actually call make_error_code
> and wrap that enum into a std::error_code. The enum is typically 4
> bytes, a std::error_code is usually 16.
> Certainly many times it doesn't matter at all but there are also times
> where it would prevent me from having a good faith argument that this is
> a strict improvement over a more C-style error handling approach.
Unlike exception_ptr, error_code has no global memory effects and is
elidable by the optimiser. Assuming there are no calls to extern
functions between the return of an error_code and the handling of it,
you will find your nominal 16 bytes reduced to a direct test of the
state of errno/GetLastError which is of course no overhead at all.
-- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk