std::basic_ostream<CharT,Traits>::tellp
提供: cppreference.com
<tbody>
</tbody>
pos_type tellp(); |
||
現在紐付けられている streambuf オブジェクトの出力位置指示子を返します。
|
(実際に出力を行わないことを除いて) UnformattedOutputFunction として動作します。 sentry オブジェクトの構築および確認の後、 |
(C++11以上) |
fail()==true の場合は pos_type(-1) を返します。 そうでなければ rdbuf()->pubseekoff(0, std::ios_base::cur, std::ios_base::out) を返します。
引数
(なし)
戻り値
成功した場合は現在の出力位置指示子、失敗した場合は pos_type(-1)。
例
Run this code
#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
関連項目
| 出力位置指示子を設定します (パブリックメンバ関数) | |
| 入力位置指示子を返します ( std::basic_istream<CharT,Traits>のパブリックメンバ関数)
| |
| 入力位置指示子を設定します ( std::basic_istream<CharT,Traits>のパブリックメンバ関数)
|