C++ Logo

std-proposals

Advanced search

Re: [std-proposals] String Slicing Draft Proposal

From: Breno Guimarães <brenorg_at_[hidden]>
Date: Mon, 18 Mar 2024 10:00:50 -0300
Hi,

Since C++23, it's now possible to use multi indexing:
https://en.cppreference.com/w/cpp/language/operators#Array_subscript_operator
So it would come naturally to add the overload:

constexpr basic_string_view basic_string::operator[](size_t start,
size_t end) const;

That would allow the syntax to be very close to python:
if (my_string[5,10] == "something") { ... }

Has that been considered?

Best REgards,
Breno G.


On Mon, Mar 18, 2024 at 9:19 AM Rhidian De Wit via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Hi all,
>
> I've now added proposed wording and incorporated more of the given
> feedback. Once again, my many thanks for the suggestions and critique!
>
> Sincerely,
>
> Op vr 15 mrt 2024 om 11:58 schreef Rhidian De Wit <rhidiandewit_at_[hidden]
> >:
>
>> Thanks to everyone so far for pointing out oversights and errors, I've
>> updated my proposal with the given feedback, and I've added a sample Github
>> project with implementation and unit tests.
>>
>> Sincerely,
>>
>> Op do 14 mrt 2024 om 09:00 schreef Jonathan Wakely <cxx_at_[hidden]>:
>>
>>>
>>>
>>> On Thu, 14 Mar 2024, 07:50 Rhidian De Wit via Std-Proposals, <
>>> std-proposals_at_[hidden]> wrote:
>>>
>>>> Hi all,
>>>>
>>>> With some helpful suggestions, I'd like to present my draft proposal
>>>> for the inclusion of several new utility functions to be added to
>>>> *std::basic_string*.
>>>>
>>>> Please reach out if you have any questions, concerns or feedback!
>>>>
>>>
>>> Your example implementations for both slice functions have undefined
>>> behaviour of the start is out of range. Is that intentional? It's not
>>> possible to tell because your technical specification doesn't really follow
>>> the form of standard specifications.
>>>
>>>
>>>
>>>
>>>
>>>> Sincerely,
>>>>
>>>> --
>>>> Rhidian De Wit
>>>> Software Engineer - Barco
>>>> --
>>>> Std-Proposals mailing list
>>>> Std-Proposals_at_[hidden]
>>>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>>>
>>>
>>
>> --
>> Rhidian De Wit
>> Software Engineer - Barco
>>
>
>
> --
> Rhidian De Wit
> Software Engineer - Barco
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-03-18 13:01:05