Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::basic_stringbuf::swap(3) C++ Standard Libarystd::basic_stringbuf::swap(3)

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

Synopsis
	  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.

Parameters
	  rhs -	another	basic_stringbuf

Return value
	  (none)

Exceptions
											(since
	  May	      throw	    implementation-defined	   exceptions.
       C++11)
											(un-
       til
											C++20)
	  noexcept						specification:
       (since
	  noexcept(std::allocator_traits<Allocator>::propagate_on_con-
       tainer_swap::value C++20)
	  || std::allocator_traits<Allocator>::is_always_equal::value)

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

Example
       // Run this code

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

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

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

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

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

Output:
	Before swap: one = "one", two =	"two".
	After  swap: one = "two", two =	"one".

See also
	  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>)

Category:
	    * conditionally noexcept

http://cppreference.com		  2024.06.10	 std::basic_stringbuf::swap(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::stringbuf::swap&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help