首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

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

二次

代码语言:javascript
复制
#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;
}

二次

产出:

二次

代码语言:javascript
复制
-1, -1, -1, -1, -1, 3.14

二次

代码语言:txt
复制
 © cppreference.com

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

扫码关注腾讯云开发者

领取腾讯云代金券