std::basic_filebuf<CharT,Traits>::showmanyc
From cppreference.com
< cpp | io | basic filebuf
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Input/output library
Print functions (C++23)
Buffers
(C++23)
(C++98/26*)
(C++20)
Streams
Abstractions
File I/O
String I/O
Array I/O
(C++23)
(C++23)
(C++23)
(C++98/26*)
(C++98/26*)
(C++98/26*)
Synchronized Output
(C++20)
Types
Error category interface
(C++11)
(C++11)
std::basic_filebuf
Public member functions
(C++11)
(C++11)
(C++26)
Protected member functions
basic_filebuf::showmanyc
Non-member functions
(C++11)
protected:
virtual std::streamsize showmanyc()
(optional)
virtual std::streamsize showmanyc()
If implemented, returns the number of characters left to read from the file.
Contents
[edit] Return value
The number of characters available for reading from the file, or -1 if the end of file was reached.
[edit] Notes
This function is optional. If not implemented, this function returns 0 (since the base class version std::basic_streambuf::showmanyc gets called).
Whether implemented or not, this function is normally called by std::basic_streambuf::in_avail if the get area is empty.
The name of this function stands for "stream: how many characters?", so it is pronounced "S how many C", rather than "show many C".
[edit] Example
An implementation test to see if showmanyc()
is implemented for std::filebuf .
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 254
[edit] See also
obtains the number of characters immediately available in the get area
(public member function of
(public member function of
std::basic_streambuf<CharT,Traits>
) [edit]