In one of the articles someone used a function data() as follows:
string work = data();
without any further reference or definition. I have an excellent book on C++ (Stanley Lippman), but data() is not mentioned as a standard function.
I searched with google but couldn't find any information, I may have used the wrong search terms.
So I went looking with kdevelop and found the definition inside string.h:
1 2 3 4 5 6 7 8 9
/**
* @brief Return const pointer to contents.
*
* This is a handle to internal data. Do not modify or dire things may
* happen.
*/
const _CharT*
data() const _GLIBCXX_NOEXCEPT
{ return _M_data(); }
What I want to know is: is this definition part of the C++ standard?
Or is it glibc dependant (like the macro entry suggests)?
Where can I find docs on this function? What does it do exactly?
There is a member function for most containers called data, but in this example string work = data(); I don't think that is what they are using. Just looking at that example alone it looks like they have made their own function called data that returns a string.