C++ Logo

std-proposals

Advanced search

Re: [std-proposals] .first() and .last() in strings

From: Richard Hodges <hodges.r_at_[hidden]>
Date: Tue, 30 Apr 2024 19:24:38 +0200
Can’t first() and last() be free functions?
Then they would not increase the surface area of std::string, and they
would work with any sequence.


On Tue, 30 Apr 2024 at 11:28, Bo Persson via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On 2024-04-30 at 09:16, Rhidian De Wit via Std-Proposals wrote:
> > Hello everyone,
> >
> > I've finally had some time to write a small proposal for a small
> > addition to std::string and std::string_view.
> > I will later add the proposed wording, but I'd already be appreciative
> > of whatever comments anyone might have.
> >
>
> The usual objection to extending std::string is of course that the
> interface is already *way* too big. Why not remove some parts instead?
> (looking at find_last_not_of) :-)
>
> Objection 2 is that this is something that can already be done in the
> existing language. Adding more ways to do the same thing is also nothing
> that C++ desperately needs.
>
> Looking at the names, it is not immediately obvious how .first() is
> related to .find_first_of(). Can this not cause confusion, similar to
> clear() vs empty()?
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-04-30 17:24:51