Rick
Rick

Reputation: 7516

Where is rdbuf()->str()?

I am trying to understand the structure of IO stream.
From cppreference std::basic_stringstream::str :

Manages the contents of the underlying string object.

1) Returns a copy of the underlying string as if by calling rdbuf()->str().

rdbuf() returns a std::basic_streambuf object, but I can't find a str() member function in https://en.cppreference.com/w/cpp/io/basic_streambuf .

Upvotes: 0

Views: 162

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596928

Look again more carefully. std::basic_stringstream::rdbuf() actually returns a pointer to a std::basic_stringbuf, not a pointer to a std::basic_streambuf as you claim.

str() is a method of std:::basic_stringbuf.

Upvotes: 3

Related Questions