std::basic_filebuf::swap
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody> void swap( std::basic_filebuf& rhs ) |
(desde C++11) | |
Trocas do estado e os conteúdos de
*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.
Parâmetros
| rhs | - | outro
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. |
Valor de retorno
(Nenhum)
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.
Notas
Esta função é chamada automaticamente quando a troca de objetos std::fstream, raramente é necessário chamá-lo diretamente.
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.
Exemplo
#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
}
Veja também
(C++11) |
atribui um objeto 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. (função pública membro) |
o algoritmo especializado 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. (modelo de função) | |
(C++11) |
troca dois fluxos de arquivo 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. (of std::basic_fstream função pública membro)
|