Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change introduces base::expected, a C++17 backport of C++23's std::expected. Similarly to other STL backports in Chromium, this port tries to replace UB with deterministic program termination where possible, and does not support exceptions. base::expected<T, E> can be thought of as a variant of the value type `T` and error type `E`, with an API similar to absl::optional<T>. Prior Art: * llvm::Expected: https://llvm.org/doxygen/classllvm_1_1Expected.html * WTF::Expected: https://github.com/WebKit/webkit/blob/main/Source/WTF/wtf/Expected.h * tl::expected: https://github.com/TartanLlama/expected * Rust's std::result::Result: https://doc.rust-lang.org/stable/std/result/enum.Result.html References: * Proposal: https://wg21.link/P0323 * C++ Draft: https://eel.is/c++draft/expected * C++ Ref: https://en.cppreference.com/w/cpp/header/expected Change-Id: I1e18de1fbec5e621805c90f1b49324db128a4681 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3453963 Reviewed-by: Giovanni Ortuno Urquidi <ortuno@chromium.org> Reviewed-by: danakj <danakj@chromium.org> Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/main@{#1002594}
- Loading branch information