stringstream から取得したストリーム buf にデータを入れています
std::stringstream data;
auto buf = data.rdbuf();
buf->sputn(XXX);
私が望むのは、ダミーデータをこのバッファに入れ、後で正しいデータを取得したら、ダミーデータを置き換えることができるようにすることです。
これらの行の何か:
auto count = 0;
buf->sputn((unsigned char *)&count, sizeof(count));
for (/*some condition*/)
{
// Put more data into buffer
// Keep incrementing count
}
// Put real count at the correct location
pubseekpos + sputn を使用してみましたが、期待どおりに動作していないようです。これを行う正しい方法は何ですか?