std::basic_...m::operator=(3)
okay bestie, gather round π this is the std::basic_istream::operator= page from the C++ Standard Libary manual β page label std::basic_...m::operator=(3), and yes the title is giving main-character energy β¨
π NAME π
std::basic_istream::operator= β std::basic_istream::operator= (the name said it twice and honestly? slay π
)
β¨ Synopsis β¨
protected: (1)
basic_istream& operator=( const basic_istream& rhs ) = delete;
protected: (2)
(since C++11)
basic_istream& operator=( basic_istream&& rhs );
πΈ Description πΈ
- The copy assignment operator is protected, and is deleted. Input streams are not
CopyAssignable. So likeβ¦ copying one? not a thing, bestie π - The move assignment operator exchanges the
gcount()values and all data members of the base class, except forrdbuf(), withrhs, as if by callingswap(*rhs). This move assignment operator is protected: it is only called by the move assignment operators of the derived movable input stream classesstd::basic_ifstreamandstd::basic_istringstream, which know how to correctly move-assign the associated streambuffers. iconic behavior, no cap π
okay but for real: both of these are protected, so donβt think you can just assign streams all willy-nilly π
π Parameters π
rhsβ thebasic_istreamobject from which to assign to*thisπ«Ά
π§ Example π§
// Run this code
#include <iostream>
#include <sstream>
int main()
{
std::istringstream s1;
s1 = std::istringstream("test"); // OK
// std::cin = std::istringstream("test"); // ERROR: 'operator=' is
protected
}
okay bye bestie π
this gem is from http://cppreference.com, dated 2024.06.10, and the page label is std::basic_...m::operator=(3) β 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