I disagree, but will leave the exercise for you.

Just will remind you that std::string is guaranteed null terminated.
Sure you can do strings like "hello\0world\0" but these are more abuse than something that is useful.
Also they won't work in C too.

const char *a = "hello\0world";
const char *b = "hello";

Does a is equal to b? It depends what you meant.
This is why my StringRef implementation uses memcmp rather than strcmp.

On Sun, Sep 13, 2020 at 9:36 PM Thiago Macieira <thiago@macieira.org> wrote:
On Sunday, 13 September 2020 11:08:17 PDT Nikolay Mihaylov wrote:
> however, the compiler knows what strcmp is , so if you do
> strcmp(a.c_str(), b.c_str()) == 0;

No, you can't. That's not the same as the *correct* memcmp.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering