std::basic_filebuf<CharT,Traits>::showmanyc
From cppreference.com
< cpp | io | basic filebuf
| protected: virtual std::streamsize showmanyc() |
(オプション) | |
実装されている場合、ファイルから読み取られる残りの文字数を返します。
目次 |
[編集] 戻り値
ファイルから読み取り可能な文字数。ファイルの終端に達した場合は -1。
[編集] 注意
この関数はオプションです。実装されていない場合、この関数は 0 を返します (基底クラスのバージョン std::basic_streambuf::showmanyc が呼び出されるため)。
実装されているかどうかにかかわらず、この関数は通常、入力領域が空の場合に std::basic_streambuf::in_avail によって呼び出されます。
この関数名は「stream: how many characters?」(ストリーム:いくつの文字?)の略であり、「show many C」ではなく「S how many C」と発音します。
[編集] 例
std::filebuf で `showmanyc()` が実装されているかどうかを確認する実装テスト。
このコードを実行
#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'; }
実行結果の例
showmanyc() returns 254
[編集] 関連項目
| 取得領域ですぐに利用可能な文字数を取得する ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| すでに利用可能な文字のブロックを抽出する ( std::basic_istream<CharT,Traits> の public メンバ関数) |