What about using Joke's trick based on reserve + c_str() ?

His suggestion is only missing a const_cast, as far as I understand...