std::ostream_iterator<T,CharT,Traits>::operator=
提供: cppreference.com
< cpp | iterator | ostream iterator
ostream_iterator& operator=( const T& value ); |
||
紐付けられたストリームに value
を挿入し、その後、構築時に指定された場合は、区切り文字を挿入します。
out_stream
を紐付けられた std::basic_ostream へのポインタ、 delim
をこのオブジェクトの構築時に指定された区切り文字とした場合、この関数の効果は以下と同等です。
*out_stream << value;
if(delim != 0)
*out_stream << delim;
return *this;
目次 |
[編集] 引数
value | - | 挿入するオブジェクト |
[編集] 戻り値
*this。
[編集] ノート
T
にはユーザ定義の operator<< を持つ任意のクラスを使用できます。
[編集] 例
Run this code
#include <iostream> #include <iterator> int main() { std::ostream_iterator<int> i1(std::cout, ", "); *i1++ = 1; // usual form, used by standard algorithms *++i1 = 2; i1 = 3; // neither * nor ++ are necessary std::ostream_iterator<double> i2(std::cout); i2 = 3.14; }
出力:
1, 2, 3, 3.14