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 11:19:48 -0300
What do you mean by "However it would be further from 2-dimensional
arrays." ? I mean, do we want it to be closer to 2-dimensional arrays?

On Mon, Mar 18, 2024 at 11:14 AM Sebastian Wittmeier via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Syntax-wise it would be nearer to Python.
>
>
>
> However it would be further from 2-dimensional arrays.
>
>
>
> Alternative - I am not sure myself about it:
>
> You could also consider adding a word, e.g. my_string[range_from_to{5,
> 10}], my_string[range_from_length{5, 10}];
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* Breno Guimarães via Std-Proposals <std-proposals_at_[hidden]>
> *Gesendet:* Mo 18.03.2024 14:16
> *Betreff:* Re: [std-proposals] String Slicing Draft Proposal
> *An:* std-proposals_at_[hidden];
> *CC:* Breno Guimarães <brenorg_at_[hidden]>; Rhidian De Wit <
> rhidiandewit_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.
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-03-18 14:20:00