strstreambuf::freeze

스트림 버퍼를 스트림 버퍼 작업을 통해 사용할 수 없게 됩니다.

void freeze(
   bool _Freezeit = true
);

매개 변수

  • _Freezeit
    A bool 스트림이 고정 시킬 것인지를 나타내는.

설명

경우 _Freezeit true 함수는 저장 된 변경 된 strstreambuf 모드로 고정 제어 되는 시퀀스를 확인 합니다.그렇지 않으면 고정 없습니다 제어 되는 시퀀스를 만듭니다.

str implies freeze.

[!참고]

중 고정 된 버퍼는 해제 되지 않습니다 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

iostream 프로그래밍

iostreams 규칙