P3981R1 — Better return types in std::inplace_vector and std::exception_ptr_cast
(5 items)
LEWG
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.
- Section 7 (References) — Bibliography entry [P3981R0] links to https://wg21.link/p3980r0 (wrong paper number 3980 instead of 3981). [1] [1]
- Header metadata table — Document number field reads P3981R0; should read P3981R1 given the R1 revision history. [2]
- Section 6 (Proposal) — Missing period before sentence-initial capitalized 'And', creating a run-on sentence. [3]
- Section 1 (Revision History) — Wrong verb tense: 'lead to deciding' should be 'led to deciding'. [4]
References — Anthropic Citations API
[1]
"Document #: P3981R0"
"Document #: P3981R0"
[2]
"discussion at a LEWG telecon lead to deciding to remove try_append_range instead of modifying it."
"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
"[endif]-->
Better return types in std
[P4022R0] Barry Revzin,..."
[4]
"to return `optional` instead of `T*` And to likewise change the return type"
"to return `optional
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.
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.