std::basic_istream<CharT,Traits>::tellg
提供: cppreference.com
< cpp | io | basic istream
pos_type tellg(); |
||
現在紐付けられている streambuf
オブジェクトの入力位置指示子を返します。
UnformattedInputFunction として動作しますが、 gcount() は影響を受けません。 sentry オブジェクトの構築および確認の後、 fail() == true であれば pos_type(-1) を返します。 そうでなければ rdbuf()->pubseekoff(0, std::ios_base::cur, std::ios_base::in) を返します。
目次 |
[編集] 引数
(なし)
[編集] 戻り値
成功した場合は get ポインタの現在位置、失敗した場合は pos_type(-1)。
[編集] 例外
内部の操作が例外を���げた場合、それはキャッチされ、 badbit がセットされます。 exceptions() が badbit
に対してセットされていれば、その例外が投げ直されます。
[編集] 例
Run this code
#include <iostream> #include <string> #include <sstream> int main() { std::string str = "Hello, world"; std::istringstream in(str); std::string word; in >> word; std::cout << "After reading the word \"" << word << "\" tellg() returns " << in.tellg() << '\n'; }
出力:
After reading the word "Hello," tellg() returns 6
[編集] 関連項目
[仮想] |
相対位置を使用してファイル位置を再設定します ( std::basic_filebuf<CharT,Traits> の仮想プロテクテッドメンバ関数)
|
[仮想] |
入力シーケンス、出力シーケンス、または両方の次ポインタの位置を、相対位置を用いて再設定します ( std::basic_stringbuf<CharT,Traits,Allocator> の仮想プロテクテッドメンバ関数)
|
[仮想] |
相対位置を使用して入力シーケンス、出力シーケンス、またはその両方の次ポインタの位置を再設定します ( std::strstreambuf の仮想プロテクテッドメンバ関数)
|
入力位置指示子を設定します (パブリックメンバ関数) | |
出力位置指示子を返します ( std::basic_ostream<CharT,Traits> のパブリックメンバ関数)
| |
出力位置指示子を設定します ( std::basic_ostream<CharT,Traits> のパブリックメンバ関数)
|