Boost logo

Boost :

Subject: Re: [boost] [system] Would it be possible to trial a breaking change to Boost.System and see what happens?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2018-01-12 18:55:57


On 01/12/18 21:46, Peter Dimov via Boost wrote:
> Andrey Semashev wrote:
>> > It will only be broken if you rely on `error_code( 0, some-category
>> )` > to contextually-convert to `false`.
>>
>> I'm not sure how I can *not* rely on that since I construct
>> `error_code` from enums or ints, all of them having 0 as the "success"
>> value precisely to allow the contextual conversion produce the
>> intended result.
>
> That's exactly what Niall wanted to know, I suppose; would it be
> possible for you to give specific examples from your code that would be
> broken?

I suppose, code like this:

   enum class my_errors
   {
     success = 0
   };

   void foo(error_code& err)
   {
     // Do stuff...
     err = make_error_code(success); // error_code(0, my_category)
   }

   void bar()
   {
     error_code err;
     foo(err);
     if (err)
       complain();
   }

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`. 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.


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