On Thu, Oct 19, 2023 at 7:13 PM Yexuan Xiao via Std-Proposals
<std-proposals@lists.isocpp.org> wrote:
>
> I propose to add a new set of find functions for basic_string and basic_string_view, which take and return iterators instead of indices. These functions will have the same name as the existing ones, but with an “x” prefix.
>
> Before:
>
> if (auto start = s.find(c); start != std::string::npos)
> {
> std::transform(s.begin() + start, s.begin() + start + c.size(), s.begin() + start, [](unsigned char c) { return std::toupper(c); });
> }
>
> After:
>
> if (auto start = s.xfind(c); start != s.end()) {
> std::transform(start, start + c.size(), start, [](unsigned char c){ return std::toupper(c); });
> }
>
> The full content using Bikeshed is here:
https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapi.csswg.org%2Fbikeshed%2F%3Furl%3Dhttps%3A%2F%2Fstorage.nykz.org%2Fproposals%2Fiterators-for-string.bs%26force%3D1&data=05%7C01%7C%7Cc0c0119772f640dd974208dbd175701d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638334074566719974%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ZwvKPr0MyJiO7seGVb8FZZI6dCI%2FWQfV6J7ugLxo4uQ%3D&reserved=0
As it currently stands, the `basic_string` API is pretty clear. Member
functions use *indicies*; if you want to do some operation on the
string using iterators, we have standard algorithms for those
operations.
We shouldn't treat algorithms like a last resort; they're a first
class feature of all ranges.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fstd-proposals&data=05%7C01%7C%7Cc0c0119772f640dd974208dbd175701d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638334074566719974%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=qTg19NGC2UjfRkOcvrOHyDyH4QivDFEu%2Btaf7xLnCK0%3D&reserved=0