std::strstreambuf:: overflow
|
protected
:
virtual int_type overflow ( int_type c = EOF ) ; |
(C++98에서 사용 중단됨)
(C++26에서 제거됨) |
|
버퍼의 put 영역에 문자 c 를 추가하며, 가능한 경우 재할당합니다.
palloc
가 사용된 경우, 해당 함수는
(
*
palloc
)
(
n
)
로 호출되며, 여기서
n
은 할당할 바이트 수입니다. 그렇지 않으면
new
char
[
n
]
가 사용됩니다. 생성자에서 해제 함수 포인터
pfree
가 사용된 경우, 필요한 경우 이전 배열을 해제하기 위해 해당 함수가
(
*
pfree
)
(
p
)
로 호출됩니다. 그렇지 않으면
delete
[
]
p
가 사용됩니다. 할당이 실패하면 함수는 실패하고
EOF
를 반환합니다.
목차 |
매개변수
| c | - | put 영역에 저장할 문자 |
반환값
만약 c == EOF 인 경우, EOF 가 아닌 다른 값을 반환합니다. 그렇지 않은 경우, 성공 시 ( unsigned char ) ( c ) 를 반환하고, 실패 시 EOF 를 반환합니다.
예제
#include <iostream> #include <strstream> struct mybuf : std::strstreambuf { int_type overflow(int_type c) { std::cout << "Before overflow(): size of the put area is " << epptr()-pbase() << " with " << epptr()-pptr() << " write positions available\n"; int_type rc = std::strstreambuf::overflow(c); std::cout << "After overflow(): size of the put area is " << epptr()-pbase() << " with " << epptr()-pptr() << " write positions available\n"; return rc; } }; int main() { mybuf sbuf; // read-write dynamic strstreambuf std::iostream stream(&sbuf); stream << "Sufficiently long string to overflow the initial allocation, at least " << " on some systems."; }
가능한 출력:
Before overflow(): size of the put area is 16 with 0 write positions available After overflow(): size of the put area is 32 with 15 write positions available Before overflow(): size of the put area is 32 with 0 write positions available After overflow(): size of the put area is 64 with 31 write positions available Before overflow(): size of the put area is 64 with 0 write positions available After overflow(): size of the put area is 128 with 63 write positions available
참고 항목
|
[virtual]
|
put 영역에서 연관된 출력 시퀀스로 문자를 기록함
(
std::basic_streambuf<CharT,Traits>
의
virtual protected member function)
|
|
[virtual]
|
출력 시퀀스에 문자를 추가함
(
std::basic_stringbuf<CharT,Traits,Allocator>
의
virtual protected member function)
|
|
[virtual]
|
put 영역에서 연관된 파일로 문자를 기록함
(
std::basic_filebuf<CharT,Traits>
의
virtual protected member function)
|
|
put 영역에 한 문자를 기록하고 다음 포인터를 전진시킴
(
std::basic_streambuf<CharT,Traits>
의
public member function)
|
|
|
문자를 삽입함
(
std::basic_ostream<CharT,Traits>
의
public member function)
|