在线文档教程
C++
迭代器 | Iterator

std::ostream_iterator::ostream_iterator

STD::Ostream[医]迭代器::ostream[医]迭代器

ostream_iterator(ostream_type& stream, const CharT* delim)(1)
ostream_iterator(ostream_type& stream)(2)

1%29构造迭代器stream作为关联的流和delim作为分隔符。

2%29构造迭代器stream作为关联流和空指针作为分隔符。

参数

stream-the output stream to be accessed by this iterator
delim-the null-terminated character string to be inserted into the stream after each output

二次

#include <iostream> #include <iterator> #include <algorithm> int main() { std::ostream_iterator<int> i1(std::cout, ", " std::fill_n(i1, 5, -1 std::ostream_iterator<double> i2(std::cout *i2++ = 3.14; }

二次

产出:

二次

-1, -1, -1, -1, -1, 3.14

二次

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/iterator/ostream[医]迭代器/O流[医]迭代器