syncbuf_type* rdbuf() const noexcept;
概要
ベースとなるstd::basic_syncbufへのポインタを返す。
戻り値
ベースとなるプライベートメンバのstd::basic_syncbufをsbとすると、次と等価である。 const_cast<syncbuf_type*>(std::addressof(sb));
例外
投げない。
例
#include <syncstream>
#include <iostream>
int main()
{
std::osyncstream bout(std::cout);
bout << "Hello, ";
auto syncbuf_ptr = bout.rdbuf();
syncbuf_ptr->emit(); // 文字が転送される
bout << "World!" << '\n';
}
出力
Hello, World!
バージョン
言語
- C++20
処理系
- Clang: ??
- GCC: 11.1 ✅
- Visual C++: 2019 update 10 ✅
参照
- P0053R7 C++ Synchronized Buffered Ostream
- LWG Issue 3127.
basic_osyncstream::rdbufneeds aconst_cast- C++20で、const版の
rdbuf()が非const版のsyncbuf_type*を返せるよう、戻り値にconst_castが追加された
- C++20で、const版の
- LWG Issue 3130. §[input.output] needs many
addressof