Context
The core API is stable on C++20. This issue tracks the C++23 tier -- features that only make sense with std::expected in the standard library and where type-erasure overhead is justified.
Already landed (C++20)
std::any payload on ErrorInfo -- attach a typed value via fail_with(payload, msg, domain)
Failure::downcast<T>() -- recover the payload as T* / const T* (returns null on mismatch or empty payload)
domain string tag for cheaper string-based discrimination when a typed payload is not needed
Changes required
std::expected aliasing
Expected<T, E> aliases std::expected<T, E> when __cplusplus >= 202302L; Unexpected aliases std::unexpected
- Evaluate whether aliasing is cleaner than a thin compatibility shim over our own
Expected
AnyhowError concept (C++20 prerequisite)
template <typename E>
concept AnyhowError = requires(E e) {
{ e.message() } -> std::convertible_to<std::string_view>;
};
Expected<T> accepts any E satisfying the concept, not just anyhow::Failure.
From-style conversion
From-style conversion for std::error_code, exception types, and third-party errors (mirrors anyhow's impl From<E> for Error)
CI
Add -std=c++23 to the build matrix.
Context
The core API is stable on C++20. This issue tracks the C++23 tier -- features that only make sense with
std::expectedin the standard library and where type-erasure overhead is justified.Already landed (C++20)
std::anypayload onErrorInfo-- attach a typed value viafail_with(payload, msg, domain)Failure::downcast<T>()-- recover the payload asT*/const T*(returns null on mismatch or empty payload)domainstring tag for cheaper string-based discrimination when a typed payload is not neededChanges required
std::expected aliasing
Expected<T, E>aliasesstd::expected<T, E>when__cplusplus >= 202302L;Unexpectedaliasesstd::unexpectedExpectedAnyhowError concept (C++20 prerequisite)
Expected<T>accepts anyEsatisfying the concept, not justanyhow::Failure.From-style conversion
From-style conversion forstd::error_code, exception types, and third-party errors (mirrors anyhow'simpl From<E> for Error)CI
Add
-std=c++23to the build matrix.