C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Iterators for basic_string and basic_string_view find functions

From: Yexuan Xiao <bizwen_at_[hidden]>
Date: Fri, 1 Sep 2023 14:07:12 +0000
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_at_[hidden]> on behalf of Jason McKesson via Std-Proposals <std-proposals_at_[hidden]>
Sent: Friday, September 1, 2023 21:36
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Jason McKesson <jmckesson_at_[hidden]>
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_at_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_at_[hidden]
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<https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals>

Received on 2023-09-01 14:07:16