std::streamsize(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 std::streamsize β€” NAME, but make it cute 🌸

okay so real talk, this is the std::streamsize(3) page from the C++ Standard Library, bestie. the literal name of the whole thing is std::streamsize β€” that's it, that's the name, no notes. she's a type, she's iconic, let's get into it πŸ’…


✨ SYNOPSIS ✨

so she lives in a header, like every good C++ girlie does:

Defined in header <ios>
typedef /*implementation-defined*/ streamsize;

that's the whole synopsis fr fr. one typedef and a vibe πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so, std::streamsize β€” hear me out β€” is an implementation-defined signed integral type. like, the standard literally says "we're not telling you exactly what it is, that's up to your implementation," iykyk. so don't go assuming a bit width, because she will not confirm it 🫢

and what does she do? she represents the number of characters transferred in an I/O operation, or the size of an I/O buffer. that's her whole job. that's the assignment and she ate πŸ’―

think of her as the signed counterpart of std::size_t β€” very "same energy, but she can go negative" β€” similar to the POSIX type ssize_t. ngl that comparison is doing a lot of work but it's true ✨

🚨 okay bestie, caveat time, do NOT skip this: except in the constructors of std::strstreambuf, negative values of std::streamsize are never used. like, never ever. so if you see a negative streamsize floating around outside std::strstreambuf constructors, something has gone deeply wrong and you should probably call someone 😭

πŸ‘‘ SEE ALSO πŸ‘‘

these are the main character functions that fw her, all of them public member functions of std::basic_istream<CharT,Traits> unless I say otherwise:

  • gcount β€” returns the number of characters extracted by the last unformatted input operation πŸ’œ (public member function of std::basic_istream<CharT,Traits>)
  • ignore β€” extracts and discards characters until the given character is found πŸŽ€ (public member function of std::basic_istream<CharT,Traits>)
  • read β€” extracts blocks of characters πŸ“– (public member function of std::basic_istream<CharT,Traits>)
  • write β€” inserts blocks of characters ✍️ (public member function of std::basic_ostream<CharT,Traits> β€” yes, notice she's an ostream one, lowkey the odd one out and we respect her for it 🌈)

and that's the page!! no cap, that's literally all of it 🧚

πŸ’Œ little sign-off from your girl: this one's from http://cppreference.com, dated 2024.06.10, and it's page std::streamsize(3) of the C++ Standard Library. go forth and stream responsibly, bestie πŸ“πŸ’–
πŸ“¦ where this page comes from