std::basic_ostream<CharT,Traits>::tellp
From cppreference.com
< cpp | io | basic_ostream
| pos_type tellp(); |
||
関連付けられている現在のstreambufオブジェクトの出力位置インジケータを返します。
|
(実際には出力を実行しないことを除き)UnformattedOutputFunctionのように動作します。セントリーオブジェクトの構築とチェックの後、 |
(C++11以降) |
もしfail()==trueならば、pos_type(-1)を返します。そうでなければ、rdbuf()->pubseekoff(0, std::ios_base::cur, std::ios_base::out)を返します。
目次 |
[編集] パラメータ
(なし)
[編集] 戻り値
成功時には現在の出力位置インジケータ、失敗時にはpos_type(-1)。
[編集] 例
このコードを実行
#include <iostream> #include <sstream> int main() { std::ostringstream s; std::cout << s.tellp() << '\n'; s << 'h'; std::cout << s.tellp() << '\n'; s << "ello, world "; std::cout << s.tellp() << '\n'; s << 3.14 << '\n'; std::cout << s.tellp() << '\n' << s.str(); }
出力
0 1 13 18 hello, world 3.14
[編集] 関連項目
| 出力位置インジケータを設定する (public member function) | |
| 入力位置インジケータを返す ( std::basic_istream<CharT,Traits> の public メンバ関数) | |
| 入力位置インジケータを設定する ( std::basic_istream<CharT,Traits> の public メンバ関数) |