public member function
<sstream>

std::basic_istringstream::rdbuf

basic_stringbuf<char_type,traits_type,allocator_type>* rdbuf() const;
獲取流緩衝區
返回指向內部 basic_stringbuf 物件的指標。

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

引數



返回值

指向內部 basic_stringbuf 物件的指標。
char_type, traits_type and allocator_type are member types defined as aliases of the class template parameters (see basic_istringstream types).

示例

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

int main () {
  std::istringstream iss;
  std::stringbuf *pbuf = iss.rdbuf();

  // using stringbuf directly:
  pbuf->str("Example string");

  int size = pbuf->in_avail();

  while (pbuf->in_avail()>0)
    std::cout << static_cast<char>(pbuf->sbumpc());

  return 0;
}

Example string


資料競爭

訪問流物件。
併發訪問同一個流物件可能導致資料爭用。

異常安全

強保證:如果丟擲異常,流緩衝區將不會發生任何更改。

另見