CppCon 2025 std::optional --- Optional Over References -- Steve Downey
Registration is now open for CppCon 2025! The conference starts on September 13 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2025!
std::optional --- Optional Over References
Tuesday, September 16 15:15 - 16:15 MDT
by Steve Downey
Summary of the talk:
Optionals were first proposed for C++ in 2005.
Optional , where T is constrained not to be a reference, was added in 2017.
Optionals for lvalue references are on track to be added in C++ 26.
What are we getting and what design choices were made? This talk will show the results.
This talk will discuss the early history of Optionals, starting with Boost.Optional and “N1878: A Proposal to Add an Utility Class to Represent Optional Objects (Revision 1)”, and what the early concerns were for the reference specialization. “P1175R0: A Simple and Practical Optional Reference for C++” then re-proposed reference support for C++20, which was not adopted. In 2020, “P1683R0: References for Standard Library Vocabulary Types - an optional<> case study” surveyed existing behavior of optional references in the wild, and pointed out the trap of assignment behavior being state dependent. In 2023, “P2988R0: Std:Optional” picked up the torch again, and Revision 10 of that is the proposal that is approved by the Library Working Group.
In 2024, “P3168R0: Give Std:Optional Range Support”, the proposal to make optional a range -- as opposed to having a separate range of zero or one -- was adopted. The reference implementation for optional
Steve Downey has been a programmer for more than 30 years. Steve graduated from SUNY Purchase with a BS in Mathematics. A Computer Science degree would have involved two classes before 11:00 am, so was impossible.
He has worked at Bloomberg since 2003, and is currently working as an Engineer on the C++ Infrastructure team.