This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.
inplace_vector(from_range_t, R&& rg)Section: 23.2.4 [sequence.reqmts], 23.3.16.2 [inplace.vector.cons] Status: WP Submitter: Hewill Kang Opened: 2025-10-01 Last modified: 2025-11-11
Priority: 3
View other active issues in [sequence.reqmts].
View all other issues in [sequence.reqmts].
View all issues with WP status.
Discussion:
Consider:
std::array<int, 42> a; std::inplace_vector<int, 5> v(std::from_range, a);
The above throws std::bad_alloc at runtime because the size of array is larger than
capacity of inplace_vector. However, we should reject it at compile time since the
array size is a constant expression.
<simd>,
it's worth applying that here as well. Compile-time errors are better than runtime ones.
[2025-10-22; Reflector poll. Status changed: New → LEWG and P3.]
General support for change, after LEWG approval.
Suggestion was made that this could be extended to all containers,
but is unlikely to be triggred in real word, as it requires ranges
with static size greater than size_t(-1).
[Kona 2025-11-06; approved by LWG. Status changed: New → Immediate.]
[Kona 2025-11-08; Status changed: Immediate → WP.]
Proposed resolution:
This wording is relative to N5014.
Modify 23.2.4 [sequence.reqmts] as indicated:
a.assign_range(rg)-60- Result:
-61- Mandates:voidassignable_from<T&, ranges::range_reference_t<R>>is modeled. Forinplace_vector, ifranges::size(rg)is a constant expression thenranges::size(rg)≤a.max_size().
Modify 23.3.16.2 [inplace.vector.cons] as indicated:
template<container-compatible-range<T> R> constexpr inplace_vector(from_range_t, R&& rg);-?- Mandates: If
-9- Effects: Constructs anranges::size(rg)is a constant expression thenranges::size(rg)≤N.inplace_vectorwith the elements of the rangerg. -10- Complexity: Linear inranges::distance(rg).