Subject: Re: [boost] [system] Would it be possible to trial a breaking change to Boost.System and see what happens?
From: Peter Dimov (lists_at_[hidden])
Date: 2018-01-12 19:03:25
Andrey Semashev wrote:
> void foo(error_code& err)
> // Do stuff...
> err = make_error_code(success); // error_code(0, my_category)
> I suppose, you could argue that I could avoid `err` initialization in
> `foo`, but that is a matter of taste and whether you want to rely on the
> initial state of `err` on entry into `foo`.
No, I'm not going to argue that; it's idiomatic to clear `err` on entry:
void foo( error_code& err )
// do stuff
with the alternative
err.assign( 0, err.category() );
being used nowadays to avoid the overhead in .clear caused by the "magic
static" Niall talks about.
This latter "idiom" is obviously broken after NIall's suggested change
> I'm also not happy to have to convert that initialization to
> err = error_code();
> because it loses information about the error category, which may be useful
> if I want to print `err` to log even if it is a success.
Interesting. You rely on there being different success error_codes? This is
also in direct opposition to the requested change.
How would you suggest we solve the problem of zero being an error in some
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk