- fstream[meta header]
- std[meta namespace]
- basic_filebuf[meta class]
- function[meta id-type]
protected:
virtual streamsize showmanyc(); // (1) C++98
streamsize showmanyc() override; // (1) C++17- streamsize[link /reference/ios/type-streamsize.md]
ブロックせずに読み取れると期待される文字数を得る。
このメンバ関数はprotectedであり、std::basic_streambufのpublicメンバ関数in_avail()を通して間接的に呼び出される。
basic_streambuf::showmanyc()と同じ動作をする。
basic_streambuf::showmanyc()と同じ。
処理系は、入力シーケンスからさらに文字を読み取れるかどうかを判断できる場合、この関数シグニチャに対するオーバーライド定義を提供してもよい。
#include <iostream>
#include <fstream>
int main()
{
{
std::filebuf out;
out.open("test.txt", std::ios_base::out);
out.sputn("ABCDE", 5);
}
std::filebuf buf;
buf.open("test.txt", std::ios_base::in);
// get領域に文字を読み込む
buf.sgetc();
// 読み込み済みの領域に残っている文字数を得る
std::cout << (buf.in_avail() > 0) << std::endl;
}- std::filebuf[link /reference/fstream/basic_filebuf.md]
- out.open[link open.md]
- buf.open[link open.md]
- out.sputn[link /reference/streambuf/basic_streambuf/sputn.md]
- buf.sgetc()[link /reference/streambuf/basic_streambuf/sgetc.md]
- buf.in_avail()[link /reference/streambuf/basic_streambuf/in_avail.md]
1
- C++98