std::ostream_iterator<T,CharT,Traits>:: operator=
| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
|
ostream_iterator::operator=
|
||||
|
ostream_iterator
&
operator
=
(
const
ostream_iterator
&
)
;
|
(1) | |
|
ostream_iterator
&
operator
=
(
const
T
&
value
)
;
|
(2) | |
如果
out_stream
是指向关联的
std::basic_ostream
的指针,且
delim
是在此对象构造时指定的分隔符,则效果等同于
*
out_stream
<<
value
;
if
(
delim
!
=
0
)
*
out_stream
<<
delim
;
return
*
this
;
目录 |
参数
| value | - | 要插入的对象 |
返回值
* this
注释
T
可以是任何定义了用户自定义
operator<<
的类。
在C++20之前,复制赋值运算符的存在依赖于 已弃用的隐式生成 。
示例
#include <iostream> #include <iterator> int main() { std::ostream_iterator<int> i1(std::cout, ", "); *i1++ = 1; // 标准形式,被标准算法使用 *++i1 = 2; i1 = 3; // 无需使用 * 或 ++ std::ostream_iterator<double> i2(std::cout); i2 = 3.14; std::cout << '\n'; }
输出:
1, 2, 3, 3.14