std::string::c_str()
returns a pointer to an array that contains a null-terminated sequence of characters (i.e., a C-string) representing the current value of t
I'd say that if c_str() returns a const char *
then its not ok, even if it can be argued to be a gray area by a language lawyer.
The way I see it is simple. The signature of the method states that the pointer it returns should not be used to modify anything.
In addition, as other commenters have pointed out, there are other ways to do the same thing that do not violate any contracts. So it's definitely not ok to do so.
That said, Borgleader has found that the language still says it isn't.