std::ostreambuf_iterator
来自cppreference.com
|
|
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
| 在头文件 <iterator> 中定义
|
||
| template< class CharT, class Traits = std::char_traits<CharT>> class ostreambuf_iterator : public std::iterator<std::output_iterator_tag, |
||
std::ostreambuf_iterator是连续的字符写入到std::basic_streambuf对象,它构建了一个单通输出迭代器。该迭代器时(不论是否解除引用或不)被分配给实际的写操作被执行。递增std::ostreambuf_iterator是一个no-op.原文:
std::ostreambuf_iterator is a single-pass output iterator that writes successive characters into the std::basic_streambuf object for which it was constructed. The actual write operation is performed when the iterator (whether dereferenced or not) is assigned to. Incrementing the std::ostreambuf_iterator is a no-op.在典型的应用中,唯一的数据成员
std::ostreambuf_iterator是一个指针,指向相关的std::basic_streambuf和一个布尔标志,表示如果文件的情况已达到.原文:
In a typical implementation, the only data members of
std::ostreambuf_iterator are a pointer to the associated std::basic_streambuf and a boolean flag indicating if the the end of file condition has been reached.目录 |
[编辑] 会员类型
| 会员类型
|
Definition |
char_type
|
CharT
|
traits_type
|
Traits
|
streambuf_type
|
std::basic_streambuf<CharT, Traits> |
ostream_type
|
std::basic_ostream<CharT, Traits> |
[编辑] 成员函数
| 构造一个新ostreambuf_iterator 原文: constructs a new ostreambuf_iterator (公共成员函数) | |
| (destructor) (隐式声明) |
destructs an ostreambuf_iterator (公共成员函数) |
| 将一个字符写入到相关的输出序列 原文: writes a character to the associated output sequence (公共成员函数) | |
| no-op (公共成员函数) | |
| no-op (公共成员函数) | |
| 测试,如果输出失败 (公共成员函数) | |
Inherited from std::iterator
Member types
| 会员类型
|
Definition |
value_type
|
void |
difference_type
|
void |
pointer
|
void |
reference
|
void |
iterator_category
|
std::output_iterator_tag |
[编辑] 示例
#include <string> #include <algorithm> #include <iterator> #include <iostream> 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 原文: input iterator that reads from std::basic_streambuf (类模板) | |
| 输出迭代器,写入std::basic_ostream 原文: output iterator that writes to std::basic_ostream (类模板) | |