std::string::c_str()

V

vch

Is it guaranteed that as long as std::string instance doesn't change it
will always return the same pointer with c_str(), and the buffer pointed
by this pointer will contain valid data while std::string instance exists?
 
V

Victor Bazarov

vch said:
Is it guaranteed that as long as std::string instance doesn't change it
will always return the same pointer with c_str(), and the buffer pointed
by this pointer will contain valid data while std::string instance exists?

No. What is guaranteed that the pointer returned by c_str() remains valid
until the next non-const member function is called for the same string.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top