23 Strings library [strings]

23.4 String classes [string.classes]

23.4.3 Class template basic_string [basic.string]

23.4.3.7 Modifiers [string.modifiers]

23.4.3.7.8 basic_string​::​swap [string.swap]

constexpr void swap(basic_string& s) noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value || allocator_traits<Allocator>::is_always_equal::value);
Preconditions: allocator_traits<Allocator>​::​propagate_on_container_swap​::​value is true or get_allocator() == s.get_allocator().
Postconditions: *this contains the same sequence of characters that was in s, s contains the same sequence of characters that was in *this.
Throws: Nothing.
Complexity: Constant time.