Home

Awesome

expected<T>

Variations on Expected<T> by Andrei Alexandrescu.

See also expected-lite - Expected objects for C++11 and later.

Refer to this blog for more information about exception_ptr lite for C++03.

Feature Comparison

Featurenonstd:: requiredstd::pairstd::optionalnonstd:: expectedBoost. ExpectedNonco expectedAndrei Expected
More informationsee [11]see [1]this worksee [4]see [3]see [5]
C++03yesyesnoyes (subset)no (union)nono
C++11yesyesyesno move sem. yetyesyesyes
DefaultConstructiblenoT paramyesyesnonono
In-place constructionnonoyesno/not yetyesyesno
Literal typenoyesyesno/not yetyesnono
Disengaged informationnopossiblenoyesyesyesyes
Vary disengaged typenoyesnomaybeyesnono
Engaged nonuse throwsyesnonopolicy?nonono
Disengaged use throwsn/anoyes, value()yes, value()yes, get()yes, get()yes, get()
Proxy (rel.ops)nonoyesyesnonono
Referencesnonoyesno/not yetnoyesno
Chained visitor(s)nononomaybemaybenono

References

[1] Fernando Cacciola and Andrzej Krzemieński. A proposal to add a utility class to represent optional objects (Revision 4). ISO/IEC JTC1 SC22 WG21 N3672 2013-04-19.

[2] Andrzej Krzemieński, Optional library implementation in C++11.

[3] Anto Nonco. Extending expected<T> to deal with references. 27 May 2013.

[4] Pierre Talbot. Boost.Expected. Unofficial Boost candidate. 5 May 2013. GitHub, GSoC 2013 Proposal, boost@lists.boost.org.

[5] Andrei Alexandrescu. Systematic Error Handling in C++. Prepared for The C++and Beyond Seminar 2012. Video. Slides.

[6] Andrei Alexandrescu. Choose your Poison: Exceptions or Error Codes? (PDF). ACCU Conference 2007.

[7] Andrei Alexandrescu. The Power of None (PPT). Northwest C++ Users' Group. May 17th, 2006.

[8] Jon Jagger. A Return Type That Doesn't Like Being Ignored. Overload issue 53, February 2003.

[9] Andrei Alexandrescu. Error Handling in C++: Are we inching towards a total solution?. ACCU Conference 2002.

[10] Ken Hagan et al. Exploding return codes. comp.lang.c++.moderated. 11 February 2000.

Notes

[11] nonstd::required: templated version of Ken Hagan's ReturnCode [10].

C++11 compiler support

Other