What about

 

s[{i, j}]
 

? It could be extended to

 

s[{i, j}, {k, l}]

 

for multi-dimensional arrays.

 

 

-----Ursprüngliche Nachricht-----
Von: Breno Guimarães via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Di 19.03.2024 18:55
Betreff: Re: [std-proposals] String Slicing Draft Proposal
An: std-proposals@lists.isocpp.org;
CC: Breno Guimarães <brenorg@gmail.com>;
For what it's worth, I strongly disagree with "s[i, j] seems actively bad". I think the level of confusion with this syntax will be minimal. I would be very surprised if developers try to "multi-index" into a string (which doesn't even make sense) and are surprised that it doesn't work.
 
Several operations in C++ have the same syntax and slightly different meanings. And several operations have drastically different meaning (like operator * and multiplication).
Another example is operator/ for std::filesystem::path. I don't recall seeing angry developers complaining that / is not dividing their path but appending.
It's all about the context.
 
Best Regards,
Breno G.