std::basic_...f::operator=(3)
πΈ NAME πΈ
okay so this page is std::basic_...f::operator=(3), straight from the C++ Standard Libary manual, and it's all about std::basic_stringbuf::operator=. The name line is literally std::basic_stringbuf::operator= β std::basic_stringbuf::operator=. It's the assignment operator for std::basic_stringbuf, and it's giving βmove it, but don't copy itβ energy π
β¨
β¨ Synopsis β¨
two overloads, bestie. one is the move assignment (since C++11), and the other is deleted. here's the exact shape:
std::basic_stringbuf& operator=( std::basic_stringbuf&& rhs );
(1) (since C++11)
std::basic_stringbuf& operator=( const std::basic_stringbuf& rhs )
(2)
= delete;
- Move assignment operator: moves the contents of
rhsinto*this. After the move,*thishas the associated string, the open mode, the locale, and all other state formerly held byrhs. The six pointers ofstd::basic_streambufin*thisare guaranteed to be different from the corresponding pointers in the moved-fromrhsunless null. no cap, that's the whole guarantee π«Ά - The copy assignment operator is deleted;
basic_stringbufis notCopyAssignable. copying is not invited to the function, bestie π
π Parameters π
rhsβ anotherbasic_stringbufthat will be moved from. that's the whole param list, and yes it's doing exactly what it says on the tin π
π Return value π
*this. that's it. iconic behavior, honestly π
π§ Example π§
there's a little // Run this code vibe in the original, so here's the exact 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 = ""
the way that move just ate and left two empty β we love to see it β¨
π See also π
- constructor β constructs a
basic_stringbufobject (public member function). lowkey the prequel, and we're obsessed π¦
π source: http://cppreference.com Β· version/date: 2024.06.10 Β· page footer: std::basic_...f::operator=(3) β bye bestie, mwah! π«Άβ¨
π¦ 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