Namespaces
Variants

std::basic_ostream<CharT,Traits>:: tellp

From cppreference.net
pos_type tellp ( ) ;
HTMLタグ、属性、および` `内のC++コードは翻訳せず、元のフォーマットを保持しました。

現在関連付けられている streambuf オブジェクトの出力位置指示子を返します。

UnformattedOutputFunction として振る舞う(ただし実際の出力は行わない)。セントリオブジェクトを構築・チェックした後、

(C++11以降)

fail ( ) == true の場合、 pos_type ( - 1 ) を返す。それ以外の場合、 rdbuf ( ) - > pubseekoff ( 0 , std:: ios_base :: cur , std:: ios_base :: out ) を返す。

目次

パラメータ

(なし)

戻り値

成功時は現在の出力位置指示子、 pos_type ( - 1 ) 失敗時は 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 member function)
入力位置指示子を設定する
( std::basic_istream<CharT,Traits> の public member function)