Created on 2025-10-01.00:00:00 last changed 1 week ago
Proposed resolution:
This wording is relative to N5014.
Modify [sequence.reqmts] as indicated:
a.assign_range(rg)-60- Result:
-61- Mandates:void
assignable_from<T&, ranges::range_reference_t<R>>
is modeled. For `inplace_vector`, if `ranges::size(rg)` is a constant expression then `ranges::size(rg)` ≤ `a.max_size()`.
Modify [inplace.vector.cons] as indicated:
template<container-compatible-range<T> R> constexpr inplace_vector(from_range_t, R&& rg);-?- Mandates: If `ranges::size(rg)` is a constant expression then `ranges::size(rg)` ≤ `N`.
-9- Effects: Constructs an `inplace_vector` with the elements of the range `rg`. -10- Complexity: Linear in `ranges::distance(rg)`.
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.
Given that we do a lot of compile-time size checking in<simd>
,
it's worth applying that here as well. Compile-time errors are better than runtime ones.
History | |||
---|---|---|---|
Date | User | Action | Args |
2025-10-04 10:32:40 | admin | set | messages: + msg15110 |
2025-10-01 00:00:00 | admin | create |