GCC: Backport std::optional and std::expected to C++14
C++14 now supports `std::optional` and `std::expected` via GCC backport.
GCC has backported implementations of std::optional and std::expected from the C++ standard library, making them available for C++14 development. The std::optional implementation was largely automated, while std::expected underwent significant restructuring. These backported features aim to provide modern C++ functionalities to users working with older standards, passing respective test suites.
In Details
This commit introduces backported implementations of std::optional and std::expected into GCC, targeting C++14 compatibility. The std::optional implementation is largely a mechanical port using an Elisp script, with manual cleanup. The std::expected implementation, however, was a substantial rewrite to ensure correctness and compatibility. Both implementations are designed to integrate seamlessly into the C++14 standard library environment, passing relevant test suites from tl::expected and libstdc++.
- std::optional
- A C++ standard library feature that represents a value that may or may not be present. It's used to handle cases where a function might not return a value, avoiding null pointers or special sentinel values.
- std::expected
- A C++ standard library feature (proposed for C++23) that represents either a value or an error. It's an alternative to exceptions for error handling, returning a result object that can hold either a success value or an error code/object.
- C++14
- A minor revision of the C++ programming language standard, released in 2014. It introduced several new features and improvements over C++11.
- libstdc++
- The C++ Standard Library implementation used by GCC. It provides containers, algorithms, I/O streams, and other essential C++ programming facilities.
- backport
- The process of taking features or fixes from a newer version of software and applying them to an older version. In this case, C++23 features are being made available for C++14.
- Elisp script
- A script written in Emacs Lisp, a Lisp dialect used for customizing and extending the Emacs text editor. Here, it's used for automated code porting.