2021年1月21日星期四

Modifying std::string internal buffer via the non-cont c++17 data() overload

I just saw that c++17 overloads a non-const data() method i.e. CharT* data() noexcept; and want to be sure that the behavior of calling it as follows is well defined:

std::string str(some_size,'0');  memcpy((void*)str.data(),source,some_size);  
https://stackoverflow.com/questions/65836035/modifying-stdstring-internal-buffer-via-the-non-cont-c17-data-overload January 22, 2021 at 05:32AM

没有评论:

发表评论