Created on 2025-10-12.00:00:00 last changed 1 month ago
Proposed resolution:
This wording is relative to N5014.
Modify [string.view.cons] as indicated:
template<class It, class End> constexpr basic_string_view(It begin, End end);-7- Constraints:
[…]
(7.1) — `It` satisfies `contiguous_iterator`.
(7.2) — `End` satisfies
sized_sentinel_for<It>.(7.3) —
is_same_v<iter_value_t<It>, charT>is `true`.(7.?) —
is_convertible_v<add_pointer_t<iter_reference_t<It>>, const_pointer>is `true`.(7.4) —
is_convertible_v<End, size_type>is `false`.template<class R> constexpr explicit basic_string_view(R&& r);-11- Let `d` be an lvalue of type
-12- Constraints:remove_cvref_t<R>.
(12.1) —
remove_cvref_t<R>is not the same type as `basic_string_view`,(12.2) — `R` models `ranges::contiguous_range` and `ranges::sized_range`,
(12.3) —
is_same_v<ranges::range_value_t<R>, charT>is `true`,(12.?) —
is_convertible_v<add_pointer_t<ranges::range_reference_t<R>>, const_pointer>is `true`,(12.4) —
is_convertible_v<R, const charT*>is `false`, and(12.5) —
d.operator ::std::basic_string_view<charT, traits>()is not a valid expression.
[ 2025-10-17; Reflector poll. ]
Set priority to 4 after reflector poll.
"NAD, don't care about volatile."
"Maybe make it Mandates: instead of Constraints:."
"We already reject span<const char> s(p,p)
so should also reject `string_view sv(p,p)`."
The following lead to a hard error in the string_view constructor
(demo):
volatile char* p;
std::string_view sv(p, p); // error: invalid conversion from 'volatile char*' to 'const char*'
Because the constructor currently only requires that the value type of the contiguous iterator be `char`, which does not reject `volatile char*`, which fires when further initializing `const char*`.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-10-17 12:42:49 | admin | set | messages: + msg15213 |
| 2025-10-12 17:10:02 | admin | set | messages: + msg15151 |
| 2025-10-12 00:00:00 | admin | create | |