std::basic_istream<CharT,Traits>::swap
提供: cppreference.com
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
protected: void swap(basic_istream& rhs); |
(C++11以上) | |
basic_ios::swap(rhs)は、すべてのデータrdbuf()を除く基本クラスのメンバ、およびスワップ
gcount()
と*thisの間rhs
カウンタの値を交換するために呼び出す。このスワップ機能が保護されています:それは、スワップ可能な入力ストリームクラスのスワップ機能によって呼び出されstd::basic_ifstreamとstd::basic_istringstream、正しく関連付けstreambuffersを交換する方法を知っている.Original:
Calls basic_ios::swap(rhs) to swap all data members of the base class except for rdbuf(), and swaps the values of the
gcount()
counters between *this and rhs
. This swap function is protected: it is called by the swap functions of the swappable input stream classes std::basic_ifstream and std::basic_istringstream, which know how to correctly swap the associated streambuffers.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
パラメータ
rhs | - | と交換するために、同じタイプの別のオブジェクトbasic_istream
Original: different basic_istream object of the same type to swap with The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
例
Run this code
#include <sstream> #include <iostream> #include <utility> int main() { std::istringstream s1("hello"); std::istringstream s2("bye"); s1.swap(s2); // OK, istringstream has a public swap() std::swap(s1, s2); // OK, calls s1.swap(s2) // std::cin.swap(s2); // ERROR: swap is a protected member std::cout << s1.rdbuf(); }
出力:
hello