std::basic_istringstream<CharT,Traits,Allocator>::str (3) - Linux Manuals
std::basic_istringstream<CharT,Traits,Allocator>::str: std::basic_istringstream<CharT,Traits,Allocator>::str
NAME
std::basic_istringstream<CharT,Traits,Allocator>::str - std::basic_istringstream<CharT,Traits,Allocator>::str
Synopsis
std::basic_string<CharT,Traits,Allocator> str() const; (1)
void str(const std::basic_string<CharT,Traits,Allocator>& new_str); (2)
Manages the contents of the underlying string object.
1) Returns a copy of the underlying string as if by calling rdbuf()->str().
2) Replaces the contents of the underlying string as if by calling rdbuf()->str(new_str).
Parameters
new_str - new contents of the underlying string
Return value
1) a copy of the underlying string object.
2) (none)
Notes
The copy of the underlying string returned by str is a temporary object that will be destructed at the end of the expression, so directly calling c_str() on the result of str() (for example in auto *ptr = out.str().c_str();) results in a dangling pointer.
Example
// Run this code
Output:
See also
str (public member function of std::basic_stringbuf<CharT,Traits,Allocator>)