A new WG21 paper is available. A copy is linked below, and the paper will also appear in the next normal WG21 mailing. If you are not a committee member, please use the comments section below or the std-proposals forum for public discussion.
Document number: N4015
by Vicente J. Botet Escriba and Pierre Talbot
expected<E,T>proposed here is a type that may contain a value of type
Tor a value of type
Ein its storage space.
Trepresents the expected value,
Erepresents the reason explaining why it doesn't contains a value of type
T, that is the unexpected value. Its interface allows to query if the underlying value is either the expected value (of type
T) or an unexpected value (of type
E). The original idea comes from Andrei Alexandrescu C++ and Beyond 2012: Systematic Error Handling in C++ talk. The interface and the rational are based on
std::optionalN3793 and Haskell monads. We can consider that
expected<E,T>is a generalization of
optional<T>providing in addition a monad interface and some specific functions associated to the unexpected type
E. It requires no changes to core language, and breaks no existing code.