Espacios de nombres
Variantes
Acciones

std::basic_stringbuf::swap

De cppreference.com
< cpp‎ | io‎ | basic stringbuf
 
 
 
 
void swap( std::basic_stringbuf& 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_stringbuf
Original:
another basic_stringbuf
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::stringstream, rara vez es necesario llamar directamente .
Original:
This function is called automatically when swapping std::stringstream 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 <sstream>
#include <string>
#include <iostream>
 
int main()
{
 
    std::istringstream one("one");
    std::ostringstream two("two");
 
    std::cout << "Before swap, one = \"" << one.str() << '"'
              << " two = \"" << two.str() << "\"\n";
 
    *one.rdbuf()->swap(*two.rdbuf());
 
    std::cout << "Before swap, one = \"" << one.str() << '"'
              << " two = \"" << two.str() << "\"\n";
}

Salida:

Before swap, one = "one" two = "two"
Before swap, one = "two" two = "one"

[editar] Ver también

Construye un objeto basic_stringbuf.
(función miembro pública) [editar]
(C++11)
swaps two string streams
(función miembro pública de std::basic_stringstream) [editar]