|
Boost : |
Subject: Re: [boost] [outcome] To variant, or not to variant?
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-01 18:52:43
> Robert Ramey wrote:
> > or
> >
> > template<class T>
> > struct outcome : public std::variant<T, std::error_code> {
> > // some special member functions
> > outcome(const std::error_code & e){...} // construct as error
> > outcome(const T & t){...} // construct legitimate result
> > };
>
> Something like this?
>
> https://github.com/pdimov/variant2/blob/develop/include/boost/variant2/result.hpp
>
> https://godbolt.org/g/EFGkCj
And here's outcome for comparison:
https://github.com/pdimov/variant2/blob/develop/include/boost/variant2/outcome.hpp
The generated code does look a bit worse, the destructor is not optimized
out.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk