C++ Logo


Advanced search

Re: why does std::basic_string should accept an std::basic_string_view with the same charT and Traits

From: Nikolay Mihaylov <nmmm_at_[hidden]>
Date: Sun, 13 Sep 2020 15:57:43 +0300
yes, allocator is part of the type.


1. you can use strings with polymorphic allocator
2. you can use standard algorithms
3. you can use strcmp() - my favourite option but I like low lever stuff.
4. with cpp17 you can convert string to string view then compare string
view's - convertion will be removed from the optimizer and you will get
strcmp() under the hood.
5. with cpp11 you can grab a class like string view and use it.
https://github.com/nmmmnu/HM4/blob/1.0.0/include/stringref.h (this might
not be the newest version i did)

if you have lots of same comparissons, you can also do custom operator ==
or whatever you need - or with cpp20 you can do tie fighter <=≥ (spaceship

Let me know I can show you some examples if you want, just tell me you want
equality or greater / less comparisson.


On Sunday, September 13, 2020, Robert Behar via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> currently I can't compare two strings with differing allocators.

Received on 2020-09-13 07:57:46