Date: Mon, 18 Mar 2024 14:17:37 +0100
Hi!
I was not aware of this feature, and indeed, it'd be great to add this to
*std::string* since it would be very close to the python example I gave!
I will add this to the proposal, with the function variant *slice()* remaining
so there is the safe variant (like *at()*) that throws when out-of-range;
and the unsafe variant (*operator[]*) that simply crashes when out-of-range.
Sincerely,
Op ma 18 mrt 2024 om 14:01 schreef Breno GuimarĂ£es <brenorg_at_[hidden]>:
> 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
>>
>
I was not aware of this feature, and indeed, it'd be great to add this to
*std::string* since it would be very close to the python example I gave!
I will add this to the proposal, with the function variant *slice()* remaining
so there is the safe variant (like *at()*) that throws when out-of-range;
and the unsafe variant (*operator[]*) that simply crashes when out-of-range.
Sincerely,
Op ma 18 mrt 2024 om 14:01 schreef Breno GuimarĂ£es <brenorg_at_[hidden]>:
> 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
>>
>
-- Rhidian De Wit Software Engineer - Barco
Received on 2024-03-18 13:17:49