Files
cppdraft_translate/cppdraft/string/swap.md
2025-10-25 03:02:53 +03:00

43 lines
1.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[string.swap]
# 27 Strings library [[strings]](./#strings)
## 27.4 String classes [[string.classes]](string.classes#string.swap)
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.swap)
#### 27.4.3.7 Modifiers [[string.modifiers]](string.modifiers#string.swap)
#### 27.4.3.7.8 basic_string::swap [string.swap]
[🔗](#lib:swap,basic_string)
`constexpr void swap(basic_string& s)
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
allocator_traits<Allocator>::is_always_equal::value);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4263)
*Preconditions*: allocator_traits<Allocator>::propagate_on_container_swap::value is true orget_allocator() == s.get_allocator()[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4269)
*Postconditions*: *this contains the same sequence of characters that was in s,s contains the same sequence of characters that was in*this[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4276)
*Throws*: Nothing[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4280)
*Complexity*: Constant time[.](#4.sentence-1)