std::ostream_iterator::ostream_iterator
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。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com