std::basic_filebuf::swap
Da cppreference.com.
< cpp | io | basic filebuf
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
void swap( std::basic_filebuf& rhs ) |
(dal C++11) | |
Scambia lo stato e il contenuto di *this e
rhs
.Original:
Swaps the state and the contents of *this and
rhs
.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.
Indice |
[modifica] Parametri
rhs | - | un altro
basic_filebuf Original: another basic_filebuf The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[modifica] Valore di ritorno
(Nessuno)
Original:
(none)
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.
[modifica] Note
Questa funzione viene chiamata automaticamente quando si sostituiscono oggetti std::fstream, raramente è necessario chiamare direttamente.
Original:
This function is called automatically when swapping std::fstream objects, it is rarely necessary to call it directly.
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.
[modifica] Esempio
#include <fstream> #include <string> #include <iostream> int main() { std::ifstream fin("test.in"); // read-only std::ofstream fout("test.out"); // write-only std::string s; getline(fin, s); std::cout << s << '\n'; // outputs the first line of test.in fin.rdbuf()->swap(*fout.rdbuf()); //swap the underlying buffers getline(fin, s); // fails: cannot read from a write-only filebuf std::cout << s << '\n'; // prints empty line }
[modifica] Vedi anche
(C++11) |
assegna un oggetto basic_filebuf Original: assigns a basic_filebuf object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) |
specializzata l'algoritmo std::swap Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) | |
(C++11) |
Scambia due flussi di file Original: swaps two file streams The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) |