std::basic_...asic_istream(3)
okay so this is the std::basic_istream::basic_istream constructor page from the C++ Standard Libary β manual name std::basic_...asic_istream(3) π
. Yes bestie, we're doing constructors today, and they are lowkey iconic.
π NAME π
std::basic_istream::basic_istream - std::basic_istream::basic_istream
β¨ Synopsis β¨
explicit basic_istream( std::basic_streambuf<CharT, Traits>* sb );
(1)
protected:
(2) (since C++11)
basic_istream( const basic_istream& rhs ) = delete;
protected:
(3) (since C++11)
basic_istream( basic_istream&& rhs );
(1)β constructs thebasic_istreamobject, assigning initial values to the base class by callingbasic_ios::init(sb). The value ofgcount()is initialized to zero. slay.(2)β the copy constructor isprotected, and it is= delete. Input streams are not copyable, periodt. π«(3)β the move constructor copies the value ofgcount()fromrhs, sets thegcount()value ofrhsto zero, and usesbasic_ios<CharT, Traits>::move(rhs)to move allbasic_iosmembers, except for therdbuf(), fromrhsinto*this. This move constructor isprotected: it is called by the move constructors of movable input stream classesstd::basic_ifstreamandstd::basic_istringstream, which know how to correctly move the associated stream buffer. iykyk π¦
π«Ά Parameters π«Ά
sbβ streambuffer to use as underlying device. the whole vibe provider, honestly.
π Example π
// Run this code
#include <iostream>
#include <sstream>
int main()
{
std::istringstream s1("hello");
std::istream s2(s1.rdbuf()); // OK: s2 shares the buffer with s1
// std::istream s3(std::istringstream("test")); // ERROR: move
constructor is protected
// std::istream s4(s2); // ERROR: copy
constructor is deleted
std::istringstream s5(std::istringstream("world")); // OK: move
ctor called
// by
derived class
std::cout << s2.rdbuf() << ' ' << s5.rdbuf() << '\n';
}
π Output: π
hello world
before you dip, bestie: the footer says source/version http://cppreference.com, date 2024.06.10, and manual name std::basic_...asic_istream(3) β love that for us ππ«Άβ¨
π¦ 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