std::basic_...f::showmanyc(3)
β¨ std::basic_filebuf::showmanyc β¨
okay so bestie, welcome to the manual page for std::basic_filebuf::showmanyc β that's the whole NAME situation, both halves, we're not skipping a single crumb π
This one's living in the C++ Standard Library and it's lowkey one of those little hidden gems you only meet when you go digging. Let's get into it π
πΈ Synopsis
protected:
virtual std::streamsize showmanyc()
So it's a protected virtual member function, and β if it's actually implemented β it hands you back the number of characters left to read from the file. that's the whole vibe. π¦
π Parameters
none. zero. nada. she takes no arguments, she needs no arguments, she's confident like that π
β Return value
She gives you the number of characters available for reading from the file β or -1 if the end of file was reached. that's it, that's the whole dealio. -1 means EOF, don't @ me π
π§ Notes
okay this part is important so listen up:
- This function is optional. If it's not implemented, it returns
0β and the reason is that the base class versionstd::basic_streambuf::showmanycgets called instead. inherited behaviour, classic π - Whether it's implemented or not, this function is normally called by
std::basic_streambuf::in_availif the get area is empty. so like, she's the backup dancer who gets called on stage when the main area's empty, yk? π - And the naming lore π«Ά β the name stands for "stream: how many characters?", which means you pronounce it "S how many C", not "show many C". this is the detail that separates the girlies who read the docs from the ones who don't. iykyk π₯
fr fr say it out loud: "S how many C". it's giving acronym, not it's giving verb. periodt.
π Example
here's an implementation test to see if showmanyc() is implemented for filebuf β cute little trick with using to expose the protected member:
// Run this code
#include <fstream>
#include <iostream>
struct mybuf : std::filebuf
{
using std::filebuf::showmanyc;
};
int main()
{
mybuf fin;
fin.open("main.cpp", std::ios_base::in);
std::cout << "showmanyc() returns " << fin.showmanyc() << '\n';
}
Possible output:
showmanyc() returns 267
(267 is not a magic number bestie, it's just however many characters were in main.cpp at the time, don't come for me π)
π See also
in_availβ obtains the number of characters immediately available in the get area (public member function ofstd::basic_streambuf<CharT,Traits>)readsomeβ extracts already available blocks of characters (public member function ofstd::basic_istream<CharT,Traits>)
π quick vibe check: this page isprotected:+virtual, optional, returns0when unimplemented,-1at EOF, and is pronounced "S how many C". that's the tea. slay. β¨
and that's the page!! source is http://cppreference.com, dated 2024.06.10, and it's the man page for std::basic_...f::showmanyc(3) β the C++ Standard Library girlies stay winning ππ«Άπ
π¦ 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