Is writing to &str[0] buffer (of a std:string) well-defined behaviour in C++11?
Yes, the code is legal in C++11 because the storage for std::string is guaranteed to be contiguous and your code avoids overwriting the terminating NULL character (or value initialized CharT). From N3337, §21.4.5 [string.access] const_reference operator[](size_type pos) const; reference operator[](size_type pos); 1 Requires: pos <= size(). 2 Returns: *(begin() + pos) if pos < size(). … Read more