public member function
<sstream>

std::ostringstream::rdbuf

stringbuf* rdbuf() const;
Get stream buffer
Returns a pointer to the internal stringbuf object, with which the object was associated on construction.

Notice however, that this is not necessarily the same as the currently associated stream buffer (returned by ios::rdbuf).

Parameters

none

Return Value

A pointer to the internal stringbuf object.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// ostringstream::rdbuf
#include <string>       // std::string
#include <iostream>     // std::cout
#include <sstream>      // std::ostringstream, std::stringbuf

int main () {
  std::ostringstream oss;

  // using stringbuf directly
  std::stringbuf *pbuf = oss.rdbuf();
  pbuf->sputn ("Sample string",13);
  std::cout << pbuf->str();

  return 0;
}


Sample string

Data races

Accesses the stream object.
Concurrent access to the same stream object may cause data races.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the stream buffer.

See also