名前空間
変種
操作

「cpp/io/basic ios/tie」の版間の差分

提供: cppreference.com
< cpp‎ | io‎ | basic ios
(1版:Translate from the English version)
 
(2人の利用者による、間の5版が非表示)
1行: 1行:
{{tr_note}}
 
 
{{cpp/io/basic_ios/title|tie}}
 
{{cpp/io/basic_ios/title|tie}}
 
{{cpp/io/basic_ios/navbar}}
 
{{cpp/io/basic_ios/navbar}}
{{ddcl list begin}}
+
{{begin}}
{{ddcl list item | num = 1 |
+
{{| num = 1 |
 
std::basic_ostream<CharT,Traits>* tie() const;
 
std::basic_ostream<CharT,Traits>* tie() const;
 
}}
 
}}
{{ddcl list item | num = 2 |
+
{{| num = 2 |
 
std::basic_ostream<CharT,Traits>* tie( std::basic_ostream<CharT,Traits>* str );
 
std::basic_ostream<CharT,Traits>* tie( std::basic_ostream<CharT,Traits>* str );
 
}}
 
}}
{{ddcl list end}}
+
{{end}}
  
{{tr|縛らストリームを管理します。縛らストリームは、ストリームバッファ({{rlpf|rdbuf}})によって制御されるシーケンスと同期化された出力ストリームです、{{c|flush()}}{{c|*this}}上の任意の入力/出力操作の前に結ばれたストリーム上で呼び出されます.|Manages the tied stream. A tied stream is a output stream which is synchronized with the sequence controlled by the stream buffer ({{rlpf|rdbuf}}), that is, {{c|flush()}} is called on the tied stream before any input/output operation on {{c|*this}}.}}
+
{{|rdbuf()}}{{c|*this}} {{c|flush()}}
  
1) {{tr|現在縛られたストリームを返します。全く縛らストリームが存在しない場合は、{{c|NULL}}が返されます.|Returns the current tied stream. If there is no tied stream, {{c|NULL}} is returned.}}
+
1
  
2) {{tr|{{tt|str}}に現在関連付けられてストリームを設定します。操作の前に縛られたストリームを返します。全く縛らストリームが存在しない場合は、{{c|NULL}}が返されます.|Sets the current tied stream to {{tt|str}}. Returns the tied stream before the operation. If there is no tied stream, {{c|NULL}} is returned.}}
+
2{{tt|str}}
  
===パラメータ===
+
======
{{param list begin}}
+
{{begin}}
{{param list item | str |{{tr| 縛らストリームとして設定する出力ストリーム| an output stream to set as the tied stream}}}}
+
{{| str | }}
{{param list end}}
+
{{end}}
  
===値を返します===
+
======
{{tr|縛らストリーム、または{{c|NULL}}全く縛らストリームが存在しなかった場合..|The tied stream, or {{c|NULL}} if there was no tied stream.}}
+
  
 
===例外===
 
===例外===
{{tr|(なし)|(none)}}
+
()
  
 
===ノート===
 
===ノート===
{{tr|デフォルトでは、標準ストリーム{{tt|cin}}、{{tt|cerr}}と{{tt|clog}}{{tt|cout}}に関連付けられています。同様に、彼らの幅広い対応{{tt|wcin}}、{{tt|wcerr}}と{{tt|wclog}}{{tt|wcout}}に関連付けられています.|By default, the standard streams {{tt|cin}}, {{tt|cerr}} and {{tt|clog}} are tied to {{tt|cout}}. Similarly, their wide counterparts {{tt|wcin}}, {{tt|wcerr}} and {{tt|wclog}} are tied to {{tt|wcout}}.}}
+
デフォルトでは、標準ストリーム {{tt|cout}} {{tt|cin}} {{tt|cerr}} {{tt|}} {{tt|wcin}} {{tt|wcerr}}
  
 
===例===
 
===例===
 
{{example|
 
{{example|
 
|code=
 
|code=
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 
|output=
 
|output=
 +
 +
 
}}
 
}}
 +
 +

2019年11月29日 (金) 00:55時点における最新版

 
 
入出力ライブラリ
入出力マニピュレータ
Cスタイルの入出力
バッファ
(C++98で非推奨)
ストリーム
抽象
ファイル入出力
文字列入出力
配列入出力
(C++98で非推奨)
(C++98で非推奨)
(C++98で非推奨)
同期化出力
エラーカテゴリインタフェース
(C++11)
 
 
std::basic_ostream<CharT,Traits>* tie() const;
(1)
std::basic_ostream<CharT,Traits>* tie( std::basic_ostream<CharT,Traits>* str );
(2)

結び付けられているストリームを管理します。 結び付けられているストリームは、ストリームバッファ (rdbuf()) によって制御されるシーケンスと同期する出力ストリームです。 つまり、 *this に対するあらゆる入出力操作の前に、結び付けられているストリームに対して flush() を呼びます。

1) 現在紐付けられているストリームを返します。 結び付けられているストリームがない場合は、ヌルポインタが返される。
2) 現在紐付けられているストリームを str に設定します。 この操作の前に結び付けられていたストリームを返します。 結び付けられていたストリームがなかった場合はヌルポインタが返されます。

目次

[編集] 引数

str - 結び付ける出力ストリーム

[編集] 戻り値

結び付けられていたストリーム、または結び付けられていたストリームがない場合はヌルポインタ。

[編集] 例外

(なし)

[編集] ノート

デフォルトでは、標準ストリーム coutcin および cerr によって tie されています。 同様に、ワイド文字版の wcoutwcin および wcerr によって tie されています。

[編集]

#include <iostream>
#include <fstream>
#include <string>
 
int main()
{
    std::ofstream os("test.txt");
    std::ifstream is("test.txt");
    std::string value("0");
 
    os << "Hello";
    is >> value;
 
    std::cout << "Result before tie(): \"" << value << "\"\n";
    is.clear();
    is.tie(&os);
 
    is >> value;
 
    std::cout << "Result after tie(): \"" << value << "\"\n";
}

出力:

Result before tie(): "0"
Result after tie(): "Hello"