Espacios de nombres
Variantes
Acciones

std::basic_filebuf::swap

De cppreference.com
< cpp‎ | io‎ | basic filebuf
 
 
Biblioteca de E/S
Manipuladores de E/S
E/S estilo C
Búferes
(en desuso en C++98)
Flujos
Abstracciones
E/S de archivos
E/S de cadenas
E/S de arrays
(en desuso en C++98)
(en desuso en C++98)
(en desuso en C++98)
Salida sincronizada
Tipos
Interfaz de categoría de error
(C++11)
 
std::basic_filebuf
Las funciones públicas miembros
Original:
Public member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_filebuf::swap
(C++11)
Protegido funciones miembro
Original:
Protected member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Terceros funciones
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
void swap( std::basic_filebuf& rhs )
(desde C++11)
Intercambia el estado y el contenido de *this y 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.

Contenido

[editar] Parámetros

rhs -
otro 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.

[editar] Valor de retorno

(Ninguno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Notas

Esta función es llamada automáticamente cuando se cambia objetos std::fstream, rara vez es necesario llamar directamente .
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.

[editar] Ejemplo

#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
 
}


[editar] Ver también

(C++11)
asigna un 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.

(función miembro pública) [editar]
Especializa el algoritmo std::swap.
(plantilla de función) [editar]
(C++11)
swaps de dos arroyos de archivos
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.

(función miembro pública de std::basic_fstream) [editar]