Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ostream_iterator<T,CharT,Traits>::operator=

      From cppreference.com
      <cpp‎ |iterator‎ |ostream iterator
       
       
      Iterator library
      Iterator concepts
      Iterator primitives
      Algorithm concepts and utilities
      Indirect callable concepts
      Common algorithm requirements
      (C++20)
      (C++20)
      (C++20)
      Utilities
      (C++20)
      Iterator adaptors
      Range access
      (C++11)(C++14)
      (C++14)(C++14)  
      (C++11)(C++14)
      (C++14)(C++14)  
      (C++17)(C++20)
      (C++17)
      (C++17)
       
       
      ostream_iterator& operator=(const ostream_iterator&);
      (1)
      ostream_iterator& operator=(const T& value);
      (2)
      1) Copy assignment operator. Assigns the contents ofother
      2) Insertsvalue into the associated stream, then inserts the delimiter, if one was specified at construction time.

      Ifout_stream is a pointer to the associatedstd::basic_ostream anddelim 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

      [edit]Parameters

      value - the object to insert

      [edit]Return value

      *this

      [edit]Notes

      T can be any class with a user-definedoperator<<.

      Prior to C++20, the existence of the copy assignment operator relied on thedeprecated implicit generation.

      [edit]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 necessarystd::ostream_iterator<double> i2(std::cout);    i2=3.14;std::cout<<'\n';}

      Output:

      1, 2, 3, 3.14
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/iterator/ostream_iterator/operator%3D&oldid=169914"

      [8]ページ先頭

      ©2009-2025 Movatter.jp