C++ Logo

std-proposals

Advanced search

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

From: connor horman <chorman64_at_[hidden]>
Date: Fri, 1 Sep 2023 16:33:41 -0400
I mean that `s.find_begin("ii");`, `s.find_begin("ii", 5);` and
`s.find_begin("ii", s.begin()+5);` should all be valid (and the latter 2
should mean the same thing) - not overloading the existing `s.find()`.

This would allow using iterators returned from s.find_begin() in subsequent
calls to find_begin.

On Fri, 1 Sept 2023 at 13:03, Yexuan Xiao <bizwen_at_[hidden]> wrote:

> I didn’t understand what you meant, do you mean to overload the function
> by the lastest parameter?
> But I think this is impossible, because when calling dependent on default
> argument, it is impossible to distinguish overloading, or remove the
> default argument of new overloads, will cause users to have to make calls
> such as s.find("ii", decltype(s)::const_iterator{}), which increases the
> difficulty of use.
> Using a new name is a more reliable solution.
>
> ------------------------------
> *From:* Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf
> of connor horman via Std-Proposals <std-proposals_at_[hidden]>
> *Sent:* Saturday, September 2, 2023 0:33
> *To:* std-proposals_at_[hidden] <std-proposals_at_[hidden]>
> *Cc:* connor horman <chorman64_at_[hidden]>
> *Subject:* Re: [std-proposals] Iterators for basic_string and
> basic_string_view find functions
>
> Adding to the colour's for the bikeshed: find_begin(P)/rfind_begin(P)
> (which returns a reverse_iterator).
>
> Can probably even be overloaded to take both an index and an iterator as
> the starting position.
>
> On Fri, Sep 1, 2023 at 11:19 Yexuan Xiao via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
> I disagree with your statement, C++23 added std::ranges::contains_subrange
> and std::string::contains at the same time, and they do not conflict.
> ------------------------------
> *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 23:06
> *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 10:04 AM Yexuan Xiao <bizwen_at_[hidden]> wrote:
> >
> > 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.
>
> Then your feature suggestion should be restricted to exactly and
> *only* those interfaces.
> --
> 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%7C559decf997ea493c5bce08dbaafd131d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638291776156014197%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=iiJRoz5Gmm%2F%2FKhEuDb8yQlt5xmFHteOdFwZbDc%2FAA%2F4%3D&reserved=0
> <https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
>

Received on 2023-09-01 20:33:56