P3981R1 — Better return types in std::inplace_vector and std::exception_ptr_cast (5 items) LEWG
Barry Revzin, Jonathan Wakely, Tomasz Kamiński
This paper proposes changing the return types of try_emplace_back and both overloads of try_push_back in std::inplace_vector from T* to optional, and changing the return type of std::exception_ptr_cast from E const* to optional. The authors argue that optional, now available in C++26, is semantically superior to raw pointers for expressing optional references, offering better API ergonomics, safer hardened access, and correct pattern matching behavior. The paper provides wording to implement these changes and bumps the relevant feature-test macros.

References — Anthropic Citations API

[1]
"Document #: P3981R0"
[2]
"discussion at a LEWG telecon lead to deciding to remove try_append_range instead of modifying it."
[3] chars 21163–24926
"[endif]-->

Better return types in std

[3] chars 111101–111329
"
https://wg21.link/p3980r0
[P4022R0] Barry Revzin,..."
[4]
"to return `optional` instead of `T*` And to likewise change the return type"
Summary: Proposes changing several return types in std::inplace_vector (try_push_back, try_emplace_back, unchecked_push_back, unchecked_emplace_back) from T* to optional/T&, and changing std::exception_ptr_cast from const E* to optional, to provide richer, safer return types.
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.