P3411R5 — any_view
(13 items)
SG9, LEWG
This paper proposes adding std::ranges::any_view, a type-erased view that can hold any object satisfying the ranges::view concept while allowing customization of traversal category, sized, borrowed, copyable, and approximately_sized properties via a bitmask enum any_view_options. The design uses a primary template with defaulted parameters so that any_view and any_view work as input ranges out of the box, while more specific configurations can be expressed by ORing option flags. Full wording is provided, including the iterator and sentinel exposition-only nested types, constexpr support, and a move-only-by-default policy.
- Section 9.2 [range.any.iterator], paragraph 18 (operator-=) — Effects are copy-pasted from operator--(int): they do not use the parameter n, perform a single decrement, and return a copy instead of *this. Should be equivalent to it -= n; return *this. [1]
- Section 9.2 [range.any.iterator], paragraph 10 (operator++(int) Remarks), cb64 — Operator precedence error: Opts & any_view_options::forward == any_view_options::forward parses as Opts & (... == ...), i.e. Opts & true. Needs parentheses: (Opts & any_view_options::forward) == any_view_options::forward. [2]
- Section 9.2 [range.any.sentinel], paragraph (2.1) of operator== — Condition says return false when y has a target sentinel object, but paragraph (2.2) then dereferences that sentinel object. The word 'no' is missing: should read 'y has no target sentinel object'. [3]
- Section 9.2 [range.any.iterator], paragraph 32 (iter_move Preconditions) — Uses '*this' but iter_move is a friend non-member function with parameter iter. Should read 'iter has a target iterator object'. [4]
- Section 9.2 [range.any.iterator], paragraph 18 (operator-=) — Missing Constraints clause. operator+= at paragraph 15 constrains on Opts & any_view_options::random_access; the symmetric operator-= has no such constraint. [5]
- Section 9.2, constructor constraints (2.11.1)-(2.11.5) — Enum name is any_view_options but constraints spell it any_views_options (extra 's') in all five occurrences. [6]
- Section 9.2 [range.any.ctor], cb45 (move assignment detailed declaration) — Synopsis declares constexpr any_view &operator=(any_view&&) noexcept but the detailed specification omits noexcept. [7]
- Section 9.2 [range.any.iterator], paragraphs 20-22 — Paragraph numbers 20, 21, and 22 each appear twice (once for operator-> and once for operator==/operator<). Second group should start at 23. [8]
- Section 9.2 [range.any.class], class synopsis cb32 (copy assignment) — Declaration is missing a trailing semicolon. [9]
- Section 6.2, cb15 (MyTraits code sample) — Declaration static constexpr move_only = true is missing the type specifier bool. [10]
- Section 10 (References), entry [ours] — Third author listed as 'Dionne Louis'; should be 'Louis Dionne' per the paper's metadata and the first-name-first convention used by all other bibliography entries. [1] [11]
References — Anthropic Citations API
[1]
"static constexpr move_only = true;"
"static constexpr move_only = true;"
[2]
""any_views_options::contiguous" (2.11.1), "any_views_options::random_access" (2.11.2), "any_views_options::bidirectional" (2.11.3), "any_views_options::forward" (2.11.4),..."
""any_views_options::contiguous" (2.11.1), "any_views_options::random_access" (2.11.2), "any_views_options::bidirectional" (2.11.3), "any_views_options::forward" (2.11.4),..."
[3]
"auto tmp = *this; --(*this); return tmp;"
"auto tmp = *this; --(*this); return tmp;"
[4]
"constexpr any_view &operator=(const any_view&)"
"constexpr any_view &operator=(const any_view&)"
[5]
"constexpr any_view &operator=(any_view&&)"
"constexpr any_view &operator=(any_view&&)"
[6]
"Paragraph 20 is used for both `operator->` Constraints ("Constraints: `Opts & any_view_options::contiguous` is `any_view_options::contiguous`") and `operator==` Constraints ("Constraints: `Opts &..."
"Paragraph 20 is used for both `operator->` Constraints ("Constraints: `Opts & any_view_options::contiguous` is `any_view_options::contiguous`") and `operator==` Constraints ("Constraints: `Opts &..."
[7]
"If either x has no target iterator object, or y has a target sentinel object, equivalent to: return false;"
"If either x has no target iterator object, or y has a target sentinel object, equivalent to: return false;"
[8]
"Preconditions: *this has a target iterator object."
"Preconditions: *this has a target iterator object."
[9]
"Opts & any_view_options::forward == any_view_options::forward"
"Opts & any_view_options::forward == any_view_options::forward"
[10]
"The specification for `operator-=(difference_type n)` at paragraph 18 only has an *Effects* clause."
"The specification for `operator-=(difference_type n)` at paragraph 18 only has an *Effects* clause."
Summary: P3411R5 proposes a type-erased view adaptor, any_view, that wraps any range satisfying a set of compile-time options (iterator category, value type, borrowability, move-only constraint) into a single type for use across ABI boundaries and in non-template contexts. The paper provides wording for a new subclause under [ranges] including the any_view class template, its type-erased iterator and sentinel, and a traits customization point. Eleven defects were found spanning specification correctness, wording consistency, and surface errors.
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.