Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::basic_stringbuf<CharT,Traits,Allocator>::operator=

      From cppreference.com
      <cpp‎ |io‎ |basic stringbuf
       
       
       
       
      (1)(since C++11)
      std::basic_stringbuf& operator=(conststd::basic_stringbuf& rhs)= delete;
      (2)
      1) Move assignment operator: Moves the contents ofrhs into*this. After the move,*this has the associated string, the open mode, the locale, and all other state formerly held byrhs. The six pointers ofstd::basic_streambuf in*this are guaranteed to be different from the corresponding pointers in the moved-fromrhs unless null.
      2) The copy assignment operator is deleted;basic_stringbuf is notCopyAssignable.

      Contents

      [edit]Parameters

      rhs - anotherbasic_stringbuf that will be moved from

      [edit]Return value

      *this

      [edit]Example

      Run this code
      #include <iostream>#include <sstream>#include <string> int main(){std::istringstream one("one");std::ostringstream two("two"); std::cout<<"Before move, one =\""<< one.str()<<'"'<<" two =\""<< two.str()<<"\"\n"; *one.rdbuf()= std::move(*two.rdbuf()); std::cout<<"After move, one =\""<< one.str()<<'"'<<" two =\""<< two.str()<<"\"\n";}

      Output:

      Before move, one = "one" two = "two"After move, one = "two" two = ""

      [edit]See also

      constructs abasic_stringbuf object
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/basic_stringbuf/operator%3D&oldid=160457"

      [8]ページ先頭

      ©2009-2025 Movatter.jp