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
Date: 2014-05-20
A proposal to add a utility class to represent expected monad
by Vicente J. Botet Escriba and Pierre Talbot
Excerpt:
Class template
expected<E,T>proposed here is a type that may contain a value of typeTor a value of typeEin its storage space.Trepresents the expected value,Erepresents the reason explaining why it doesn't contains a value of typeT, that is the unexpected value. Its interface allows to query if the underlying value is either the expected value (of typeT) or an unexpected value (of typeE). The original idea comes from Andrei Alexandrescu C++ and Beyond 2012: Systematic Error Handling in C++ talk. The interface and the rational are based onstd::optionalN3793 and Haskell monads. We can consider thatexpected<E,T>is a generalization ofoptional<T>providing in addition a monad interface and some specific functions associated to the unexpected typeE. It requires no changes to core language, and breaks no existing code.

Add a Comment
Comments are closed.