strstreambuf::freeze

ストリームのバッファーをストリームのバッファーの操作によって使用できなくなります。

void freeze(
   bool _Freezeit = true
);

パラメーター

  • _Freezeit
    ストリームに固定するかどうかを示す bool。

解説

_Freezeit が true の場合、関数は固定被制御シーケンスを作成するための格納済み strstreambuf モードを変更します。それ以外の場合は、固定被制御シーケンスを作成します。

strfreezeを意味します。

[!メモ]

フリーズするバッファーは strstreambuf の破棄時に解放されません。メモリ リークを回避することを解放する前にバッファーを解凍する必要があります。

使用例

// strstreambuf_freeze.cpp
// compile with: /EHsc

#include <iostream>
#include <strstream>

using namespace std;

void report(strstream &x)
{
    if (!x.good())
        cout << "stream bad" << endl;
    else
        cout << "stream good" << endl;
}

int main()
{
    strstream x;

    x << "test1";
    cout << "before freeze: ";
    report(x);

    // Calling str freezes stream.
    cout.write(x.rdbuf()->str(), 5) << endl;
    cout << "after freeze: ";
    report(x);

    // Stream is bad now, wrote on frozen stream
    x << "test1.5";
    cout << "after write to frozen stream: ";
    report(x);

    // Unfreeze stream, but it is still bad
    x.rdbuf()->freeze(false);
    cout << "after unfreezing stream: ";
    report(x);

    // Clear stream
    x.clear();
    cout << "after clearing stream: ";
    report(x);

    x << "test3";
    cout.write(x.rdbuf()->str(), 10) << endl;

    // Clean up.  Failure to unfreeze stream will cause a
    // memory leak.
    x.rdbuf()->freeze(false);
}
  

必要条件

ヘッダー: <strstream>

名前空間: std

参照

関連項目

strstreambuf Class

入出力ストリームのプログラミング

入出力ストリームの規則