Boost logo

Boost :

Subject: Re: [boost] [outcome] High level summary of review feedback accepted so far
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-05-31 10:55:51


> Returning a pointer actually only superficially looks like you are
> protecting yourself from the narrow contract. You just force the caller to
> use narrow contract function on the pointer.
> This reminds me that at some point people here in Boost discussed that
> get<T>() accessor on variant<T, U, V> should return optional<T&>.

What the C++ 17 standard eventually did was to add a
std::get_if<I>(&variant) which returns a pointer to the value if the
variant is in that state. std::get<I>(variant) throws an exception if
you don't use the right state.

I guess, ultimately, the question to be answered here is how much like
std::variant<...> should Outcome and/or Expected be? std::variant<...>
doesn't implement completely unchecked observers like optional's
operator*(), the best you can get is a nulled pointer observer, no
silent reinterpret_cast.

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