std::ostreambuf_iterator
| 헤더에 정의됨 <iterator>
|
||
template< class CharT, class Traits = std::char_traits<CharT> >
class ostreambuf_iterator
: public std::iterator<std::output_iterator_tag, void, void, void, void>
|
(C++17까지) | |
template< class CharT, class Traits = std::char_traits<CharT> >
class ostreambuf_iterator;
|
(C++17부터) | |
std::ostreambuf_iterator 는 단일 패스 LegacyOutputIterator 로, 생성된 std::basic_streambuf 객체에 연속적인 문자를 씁니다. 실제 쓰기 연산은 반복자(역참조 여부와 관계없이)에 할당될 때 수행됩니다. std::ostreambuf_iterator를 증가시키는 것은 아무런 효과가 없습니다.
일반적인 구현에서 std::ostreambuf_iterator의 유일한 데이터 멤버는 연결된 std::basic_streambuf에 대한 포인터와 파일 끝 조건에 도달했는지 여부를 나타내는 부울 플래그입니다.
멤버 타입
| 멤버 타입 | 정의 | ||||
iterator_category
|
std:: output_iterator_tag | ||||
value_type
|
void | ||||
difference_type
|
|
||||
pointer
|
void | ||||
reference
|
void | ||||
char_type
|
CharT
|
||||
traits_type
|
Traits
|
||||
streambuf_type
|
std:: basic_streambuf < CharT, Traits > | ||||
ostream_type
|
std:: basic_ostream < CharT, Traits > |
|
멤버 타입
|
(C++17 이전) |
멤버 함수
새로운
ostreambuf_iterator
를 생성합니다
(public member function) |
|
|
(destructor)
(implicitly declared)
|
ostreambuf_iterator
를 파괴합니다
(public member function) |
|
문자를 연관된 출력 시퀀스에 기록합니다
(public member function) |
|
|
no-op
(public member function) |
|
|
no-op
(public member function) |
|
|
출력 실패 여부를 검사합니다
(public member function) |
예제
#include <algorithm> #include <iostream> #include <iterator> #include <string> int main() { std::string s = "This is an example\n"; std::copy(s.begin(), s.end(), std::ostreambuf_iterator<char>(std::cout)); }
출력:
This is an example
참고 항목
|
std::basic_streambuf
에서 읽어들이는
입력 반복자
(클래스 템플릿) |
|
|
std::basic_ostream
에 기록하는
출력 반복자
(클래스 템플릿) |