21 Strings library [strings]

21.3 String classes [string.classes]

21.3.3 Class template basic_­string [basic.string]

21.3.3.7 Modifiers [string.modifiers]

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