M
Metro12
In the <basic_string.h>, I find the implementation of these two
functions. But I can't understand the difference between them.
Please give me some help!
//basic_string::c_str()
const _CharT*
c_str() const
{
// MT: This assumes concurrent writes are OK.
size_type __n = this->size();
traits_type::assign(_M_data()[__n], _Rep::_S_terminal);
return _M_data();
}
//basic_string::data()
const _CharT*
data() const { return _M_data(); }
Thanks!
functions. But I can't understand the difference between them.
Please give me some help!
//basic_string::c_str()
const _CharT*
c_str() const
{
// MT: This assumes concurrent writes are OK.
size_type __n = this->size();
traits_type::assign(_M_data()[__n], _Rep::_S_terminal);
return _M_data();
}
//basic_string::data()
const _CharT*
data() const { return _M_data(); }
Thanks!