P3981R0 — Better return types in std::inplace_vector and std::exception_ptr_cast (4 items) LEWG
Barry Revzin, Jonathan Wakely, Tomasz Kamiński
This paper proposes changing the return types of try_emplace_back and try_push_back in std::inplace_vector from T* to optional, changing try_append_range from ranges::borrowed_iterator_t to ranges::borrowed_subrange_t, and changing std::exception_ptr_cast from E const* to optional. The motivation is that optional, now adopted for C++26, is semantically clearer, provides a richer and safer API, and better reflects the fallible nature of these operations compared to raw pointers, which carry misleading ownership and array semantics.

References — Anthropic Citations API

[1]
"Barry wrote a whole blog post several years about about how T* makes for a poor optional responding to this claim."
[2]
"We we don't have an owning pointer, so neither delete nor delete [] are valid."
[3]
"where it is «-«-The-»-» first iterator in the range ranges::begin(rg)+[0, n) that was not inserted into *this"
Summary: Proposes changing several standard library functions in std::inplace_vector and std::exception_ptr_cast to return optional or optional instead of raw pointers, aligning their return types with the vocabulary types the committee has adopted since these APIs were originally designed.
Pipeline: Discovery (Anthropic Opus + Citations API) → Verification Gate (OpenRouter Opus) → Report Writer (OpenRouter Opus)
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.