C++23: An Overview of Almost All New and Updated Features - Marc Gregoire - CppCon 2023

Get an in-depth overview of the new and updated features in C++23, including `std::span`, `std::optional`, `std::variant`, improved error handling, and more, from esteemed speaker Marc Gregoire at CppCon 2023.

Key takeaways
  • C++23 introduces new and updated features, expanding on what was available in C++20.
  • std::span allows for easy manipulation of arrays or other containers, and std::mdspan supports multi-dimensional memory layouts.
  • std::optional adds new methods, including as_value, as_error and value, and std::variant is deprecated.
  • The <format> header provides new string formatting APIs, including std::format and std::formattoa.
  • range library enhancements include flatten, to, first, and last algorithms.
  • std::visit allows for flexible and concise expression of visit operation.
  • C++23 supports const eval, which permits evaluation of expressions at compile time if possible.
  • std::monostate allows for creation of functions that can’t be instantiated.
  • Improvements to error handling, including unwrap and unwrap_or_default for std::optional.
  • Garbage collection APIs are available, including std::unique_ptr.
  • Lambda expressions can now explicitly capture by value.
  • Overloadable std::as_const is added.
  • More concise code can be achieved by using nden for lazy evaluation of optional values.
  • Performance improvements through reduction of unnecessary checking and reallocation.
  • Changes to string and character representation, including integer literal suffix and extended character literal syntax.
  • Extensions to set and map literals, including initialization with a type.
  • Improved support for array and vector views.
  • Enhanced usability of std::span and std::mdspan.
  • std::erase and std::erase_if to remove elements from containers.
  • Many other minor improvements and fixes.

Note: Some of the described features are new in C++20, but also have enhancements in C++23.