Boost logo

Boost :

Subject: Re: [boost] expected/result/etc
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2016-01-26 05:03:46

On 26 Jan 2016 at 0:16, Michael Marcin wrote:

> Some months ago there was a lot of discussion regarding Rust style
> return values for non-exceptional error handling.

Mine was one of many discussed. Its current name is Outcome.

> Did anything ever come of this?

Yes, Outcome continues to mature as it is being used to write AFIO
v2. The non-futurey bits are quite mature by now and have seen very
extensive usage. The futurey bits aren't being used in the AFIO v2
rewrite yet, and so haven't had the same quantity of very fine level

If I do say so myself, it is *spectacularly* well suited to this use
case, producing seriously high quality assembler output. I am very,
very pleased with it.

> Is there a useable library?

It requires VS2015 Update 1 or newer, or any C++ 14 compiler. Some
example AFIO v2 code using it:

As you'll see, the enormous win is that almost every function apart
from constructors is now noexcept. That causes the compiler to do a
very good job indeed of inlining and eliminating code from the
assembler output, plus static analysis tools spot when you forget to
properly handle an errored return because it'll try throwing in a
noexcept function. I expect AFIO v2 to have an undetectable overhead
relative to syscalls, even no op syscalls.

Two big items remain todo for Outcome:

1. I want to write a clang-tidy extension which rewrites any outcome
returning function to be noexcept unless commented otherwise. This
prevents one forgetting to add noexcept.

2. I want another clang-tidy extension to mark up outcome returning
functions with the compiler-specific markup to complain if you forget
to do something with the returned value. Right now outcomes have the
same problem as C error returns, one can forget to handle them

I also strongly emphasise that nothing in Outcome is fixed, things
may yet change. Outcome is not in the Boost review queue, nor may
never be.


ned Productions Limited Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at