← Back to context

Comment by throwaway2037

11 hours ago

Doesn't C++'s std::string also use a null terminated char* string internally? Do you count that also?

Since C++11 it is required to be null-terminated, you can access the terminator with (for e.g.) operator[], and the string can contain non-terminator null characters.

It has nul-termination for compatibility with C, so you can call c_str and get a C string. With the caveat that an std::string can have nuls anywhere, which breaks C semantics. But C++ does not use that itself.

This doesn't count because it's implemented in a way "if you don't need null-terminated string, you won't see it".