Namespaces
Variants
Actions

std::basic_string<CharT,Traits,Allocator>::swap

From cppreference.com
< cpp‎ | string‎ | basic string
 
 
 
std::basic_string
 
void swap( basic_string& other );
(until C++17)
void swap( basic_string& other ) noexcept(/* see below */);
(since C++17)
(constexpr since C++20)

Exchanges the contents of the string with those of other. All iterators and references may be invalidated.

If std::allocator_traits<allocator_type>::propagate_on_container_swap::value is true, then the allocators are exchanged using an unqualified call to non-member swap. Otherwise, they are not swapped (and if get_allocator() != other.get_allocator(), the behavior is undefined).

(since C++11)

Contents