std::ostrea...::operator=(3)
β¨ std::ostrea...::operator=(3) β¨
okay so welcome to std::ostrea...::operator=(3), straight out of the C++ Standard Libary manual, bestie. This is the page for the assignment operator on std::ostream_iterator, and yes itβs giving βtiny operator, big stream energyβ π
. Letβs get into it.
πΈ NAME πΈ
std::ostream_iterator::operator= β std::ostream_iterator::operator=
fr fr, thatβs the name. Nothing extra, just iconic repetition π«Ά.
π¦ Synopsis π¦
ostream_iterator& operator=( const ostream_iterator& ); (1)
ostream_iterator& operator=( const T& value ); (2)
- (1) Copy assignment operator. Assigns the contents of
other. - (2) Inserts
valueinto the associated stream, then inserts the delimiter, if one was specified at construction time.
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;
Thatβs the whole vibe check: shove value into *out_stream, then if delim != 0, shove delim too, and hand back *this π.
π Parameters π
valueβ the object to insert
π Return value π
*this β and thatβs on periodt β¨.
π Notes π
Tcan be any class with a user-definedoperator<<.- Prior to C++20, the existence of the copy assignment operator relied on the deprecated implicit generation.
heads up bestie: βdeprecatedβ is right there in the original, so donβt come for me β thatβs a real caveat π«Ά.
π₯ Example π₯
// 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;
std::cout << '\n';
}
π Output π
1, 2, 3, 3.14
okay thatβs the whole assignment-operator saga, bestie π«Ά β sourced from http://cppreference.com, date/version 2024.06.10, and the page name is std::ostrea...::operator=(3). stay slay, and may your delimiters always pass the vibe check π
β¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms