Boost logo

Boost :

Subject: Re: [boost] Boost.Outcome review - First questions
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-05-24 01:29:11


On 24/05/2017 02:17, Gavin Lambert via Boost wrote:
> On 24/05/2017 03:19, Niall Douglas wrote:
>> I never found a use for that particular variety in my own code, but I
>> find the semantics very attractive. They impose rigour. I just wish I
>> could make the statically obvious failure to collect state a compile
>> time instead of runtime error.
>
> I mentioned earlier that if the entire result<T> or outcome<T> class
> were declared [[nodiscard]] then this should have the effect of the
> compiler issuing warnings and/or errors if one is returned from a method
> and the caller fails to do *something* with it.

That is already the case.

> Sadly this is C++17-only. Though I dimly recall another technique
> involving rvalue methods that only requires C++11 being used in another
> proposed library. It's possible that I am recalling incorrectly and
> this was also runtime-only validation, however.

If the compiler advertises itself as providing [[nodiscard]], Outcome
uses it. Many compilers do, even in less than C++-17 mode. For older
compilers, Outcome will use compiler-specific markup to achieve the same
warning where available e.g. under the MSVC static analyser.

Niall

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