これらは、<ostream>
で定義されているグローバル テンプレート関数です。 メンバー関数については、 basic_ostream
クラス のドキュメントを参照してください。
endl
行を終了し、バッファーをフラッシュします。
template class<Elem, Tr>
basic_ostream<Elem, Tr>& endl(
basic_ostream<Elem, Tr>& Ostr);
パラメーター
Elem
要素タイプ。
Ostr
basic_ostream
型オブジェクト。
Tr
文字の特徴 (traits)。
戻り値
basic_ostream
型オブジェクト。
解説
マニピュレーターは Ostr
.put
を呼び出します(Ostr
.widen
('\n')) を呼び出し、 Ostr
.flush
を呼び出します。
Ostr
を返します。
例
// ostream_endl.cpp
// compile with: /EHsc
#include <iostream>
int main( )
{
using namespace std;
cout << "testing" << endl;
}
testing
ends
文字列を終了します。
template class<Elem, Tr>
basic_ostream<Elem, Tr>& ends(
basic_ostream<Elem, Tr>& Ostr);
パラメーター
Elem
要素タイプ。
Ostr
basic_ostream
型オブジェクト。
Tr
文字の特徴 (traits)。
戻り値
basic_ostream
型オブジェクト。
解説
マニピュレーターは Ostr
.put
を呼び出します(Elem
('\0'))。
Ostr
を返します。
例
// ostream_ends.cpp
// compile with: /EHsc
#include <iostream>
int main( )
{
using namespace std;
cout << "a";
cout << "b" << ends;
cout << "c" << endl;
}
ab c
flush
バッファーをフラッシュします。
template class<Elem, Tr>
basic_ostream<Elem, Tr>& flush(
basic_ostream<Elem, Tr>& Ostr);
パラメーター
Elem
要素タイプ。
Ostr
basic_ostream
型オブジェクト。
Tr
文字の特徴 (traits)。
戻り値
basic_ostream
型オブジェクト。
解説
マニピュレーターは Ostr
.flush
を呼び出します。
Ostr
を返します。
例
// ostream_flush.cpp
// compile with: /EHsc
#include <iostream>
int main( )
{
using namespace std;
cout << "testing" << flush;
}
testing
swap
2 つの basic_ostream
オブジェクトの値を交換します。
template <class Elem, class Tr>
void swap(
basic_ostream<Elem, Tr>& left,
basic_ostream<Elem, Tr>& right);
パラメーター
Elem
要素タイプ。
Tr
文字の特徴 (traits)。
left
basic_ostream
オブジェクトへの左辺値参照。
right
basic_ostream
オブジェクトへの左辺値参照。
解説
テンプレート関数 swap
は、left.swap(right)
を実行します。