GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::basic_stringbuf::swap(3) C++ Standard Libary std::basic_stringbuf::swap(3)

std::basic_stringbuf::swap - std::basic_stringbuf::swap


void swap( basic_stringbuf& rhs ); (since C++11)
(until C++20)
void swap( basic_stringbuf& rhs ) noexcept(/* see below */); (since C++20)


Swaps the state and the contents of *this and rhs.


The behavior is undefined if Allocator does not propagate on swap and (since C++11)
the allocators of *this and other are unequal.


rhs - another basic_stringbuf


(none)


(since
May throw implementation-defined exceptions. C++11)
(until
C++20)
noexcept specification: (since
noexcept(std::allocator_traits<Allocator>::propagate_on_container_swap::value C++20)
|| std::allocator_traits<Allocator>::is_always_equal::value)


This function is called automatically when swapping std::stringstream objects, it is
rarely necessary to call it directly.

// Run this code


#include <sstream>
#include <string>
#include <iostream>
#include <iomanip>


int main()
{
std::istringstream one("one");
std::ostringstream two("two");


std::cout << "Before swap, one = " << std::quoted( one.str() )
<< " two = " << quoted( two.str() ) << '\n';


one.rdbuf()->swap(*two.rdbuf());


std::cout << "After swap, one = " << quoted( one.str() )
<< " two = " << quoted( two.str() ) << '\n';
}


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


constructor constructs a basic_stringbuf object
(public member function)
swap swaps two string streams
(C++11) (public member function of
std::basic_stringstream<CharT,Traits,Allocator>)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.