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) | |
If
out_stream
is a pointer to the associated
std::basic_ostream
and
delim
is the delimiter specified at the construction of this object, then the effect is equivalent to
*
out_stream
<<
value
;
if
(
delim
!
=
0
)
*
out_stream
<<
delim
;
return
*
this
;
Contents |
Parameters
| value | - | the object to insert |
Return value
* this
Notes
T
can be any class with a user-defined
operator<<
.
Prior to C++20, the existence of the copy assignment operator relied on the deprecated implicit generation .
Example
#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; std::cout << '\n'; }
Output:
1, 2, 3, 3.14