Vector's new method data() provides a const and non-const version.
However string's data() method only provides a const version.
I think they changed the wording about std::string so that the chars are now required to be contiguous (like std::vector).
Was std::string::data just missed? Or is the a good reason to only allow const access to a string's underlying characters?
note: std::vector::data has another nice feature, it's not undefined behavior to call data() on an empty vector. Whereas &vec.front() is undefined behavior if it's empty.
std::vector::datareturns null when the vector is empty. Why is that a nice feature?std::vector::datais not spec'd to return NULL.f(v.empty() ? NULL : &v.front())is quite a mouthful, though, compared tof(v.data()).