Created on 2017-11-29.00:00:00 last changed 46 months ago
Proposed resolution:
This wording is relative to N4713.
Change [string.view.ops] p20 as indicated:
constexpr bool starts_with(basic_string_view x) const noexcept;-20- Effects: Equivalent to: return substr(0, x.size()) == x
compare(0, npos, x) == 0;
Change [string.view.ops] p21 as indicated:
constexpr bool starts_with(charT x) const noexcept;-21- Effects: Equivalent to: return !empty() && traits::eq(front(), x)
starts_with(basic_string_view(&x, 1));
Change [string.view.ops] p24 as indicated:
constexpr bool ends_with(charT x) const noexcept;-24- Effects: Equivalent to: return !empty() && traits::eq(back(), x)
ends_with(basic_string_view(&x, 1));
[ 2018-10-29 Moved to Tentatively Ready after 5 positive votes for P0 on c++std-lib. ]
[ 2018-01-23, Reopening due to a comment of Billy Robert O'Neal III requesting a change of the proposed wording ]
The currently suggested wording has:
Effects: Equivalent to: return size() >= x.size() && compare(0, x.size(), x) == 0;
but compare() already does the size() >= x.size() check.
It seems like it should say:Effects: Equivalent to: return substr(0, x.size()) == x;
[ 2017-12-13 Moved to Tentatively Ready after 8 positive votes for P0 on c++std-lib. ]
Previous resolution: [SUPERSEDED]This wording is relative to N4713.
Change [string.view.ops] p20 as indicated:
constexpr bool starts_with(basic_string_view x) const noexcept;-20- Effects: Equivalent to: return size() >= x.size() && compare(0,
nposx.size(), x) == 0;Change [string.view.ops] p21 as indicated:
constexpr bool starts_with(charT x) const noexcept;-21- Effects: Equivalent to: return !empty() && traits::eq(front(), x)
starts_with(basic_string_view(&x, 1));Change [string.view.ops] p24 as indicated:
constexpr bool ends_with(charT x) const noexcept;-24- Effects: Equivalent to: return !empty() && traits::eq(back(), x)
ends_with(basic_string_view(&x, 1));
The effects of starts_with are described as equivalent to return compare(0, npos, x) == 0.
This is incorrect, because it returns false when you check to see if any sequence begins with the empty sequence. (There are other failure cases, but that one's easy) As a drive-by fix, we can make the Effects: for starts_with and ends_with clearer. Those are the second and proposed third changes, and they are not required.History | |||
---|---|---|---|
Date | User | Action | Args |
2021-02-25 10:48:01 | admin | set | status: wp -> c++20 |
2019-02-26 17:40:23 | admin | set | status: voting -> wp |
2019-01-21 04:50:04 | admin | set | status: ready -> voting |
2018-10-29 17:30:42 | admin | set | messages: + msg10170 |
2018-10-29 17:30:42 | admin | set | status: open -> ready |
2018-01-24 20:16:41 | admin | set | messages: + msg9628 |
2018-01-24 20:16:41 | admin | set | status: ready -> open |
2017-12-13 18:11:46 | admin | set | messages: + msg9587 |
2017-12-13 18:11:46 | admin | set | status: new -> ready |
2017-12-02 13:38:19 | admin | set | messages: + msg9575 |
2017-11-29 00:00:00 | admin | create |