[Deleted, misread]
Since C++11, data() is also required to be null terminated. Per your own source and cppreference.
std::string since C++ 11 guarantees the buffer is zero terminated. The reasoning being thread safety of const members. https://eel.is/c++draft/basic.string#general-3
Since C++11, data() is also required to be null terminated. Per your own source and cppreference.