public member function
<sstream>

std::basic_stringstream::rdbuf

basic_stringbuf<char_type,traits_type,allocator_type>* rdbuf() const;
Get stream buffer
Returns a pointer to the internal basic_stringbuf object.

Notice however, that this is not necessarily the same as neither of its currently associated stream buffers (as returned by inherited basic_ios::rdbuf members).

Parameters

none

Return Value

A pointer to the internal basic_stringbuf object.
char_type, traits_type and allocator_type are member types defined as aliases of the class template parameters (see basic_stringstream types).

Example

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

int main () {
  std::stringstream ss;

  // using stringbuf directly:
  std::stringbuf *pbuf = ss.rdbuf();
  pbuf->sputn ("Example string",13);

  char buffer[80];
  pbuf->sgetn (buffer,80);

  std::cout << buffer;

  return 0;
}

Example 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