std::string requires work with string literals, therefore the member function `size_type find(const CharT* s, size_type pos = 0) const;` is a commonly used version, while std::ranges::find cannot directly achieve the same functionality.


From: Std-Proposals <std-proposals-bounces@lists.isocpp.org> on behalf of Jason McKesson via Std-Proposals <std-proposals@lists.isocpp.org>
Sent: Friday, September 1, 2023 21:36
To: std-proposals@lists.isocpp.org <std-proposals@lists.isocpp.org>
Cc: Jason McKesson <jmckesson@gmail.com>
Subject: Re: [std-proposals] Iterators for basic_string and basic_string_view find functions
 
On Fri, Sep 1, 2023 at 8:18 AM 萧 叶轩 via Std-Proposals
<std-proposals@lists.isocpp.org> wrote:
>
> Abstract
>
> This paper proposes to add iterator-based versions of the find family of functions for basic_string and basic_string_view, and deprecate the index-based versions. This is to align with the iterator-based interface of the C++ standard library. The current use of indices and npos is inconsistent with the C++ style and causes confusion and inefficiency.

Why do they need iterator-based member functions for finding when we
have iterator-based algorithms that can do the same job? Is
`x.find(...)` really so much better than `find(x, ...)`? And if it is
so much better, why shouldn't these be on all containers and views?
--
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%7C0005e25bb6a54f5375e108dbaaf0835a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638291722211796028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=wno5wGdt4e1J0LWrfONEKOq0pmGHgNJOEWUjOH1wDIM%3D&reserved=0