76 lines
3.2 KiB
Markdown
76 lines
3.2 KiB
Markdown
[string.require]
|
||
|
||
# 27 Strings library [[strings]](./#strings)
|
||
|
||
## 27.4 String classes [[string.classes]](string.classes#string.require)
|
||
|
||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.require)
|
||
|
||
#### 27.4.3.2 General requirements [string.require]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2363)
|
||
|
||
If any operation would cause size() to
|
||
exceed max_size(), that operation throws an
|
||
exception object of type length_error[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2368)
|
||
|
||
If any member function or operator of basic_string throws an exception, that
|
||
function or operator has no other effect on the basic_string object[.](#2.sentence-1)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2372)
|
||
|
||
Every object of typebasic_string<charT, traits, Allocator> uses an object of typeAllocator to allocate and free storage for the contained charT objects as needed[.](#3.sentence-1)
|
||
|
||
The Allocator object used is
|
||
obtained as described in [[container.reqmts]](container.reqmts "23.2.2.2 Container requirements")[.](#3.sentence-2)
|
||
|
||
In every specialization basic_string<charT, traits, Allocator>,
|
||
the type traits shall meet
|
||
the character traits requirements ([[char.traits]](char.traits "27.2 Character traits"))[.](#3.sentence-3)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
Every specialization basic_string<charT, traits, Allocator> is
|
||
an allocator-aware container ([[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5 Allocator-aware containers")),
|
||
but does not use the allocator's construct and destroy member functions ([[container.requirements.pre]](container.requirements.pre "23.2.1 Preamble"))[.](#3.sentence-4)
|
||
|
||
The program is ill-formed ifAllocator::value_type is not the same type as charT[.](#3.sentence-5)
|
||
|
||
â *end note*]
|
||
|
||
[*Note [2](#note-2)*:
|
||
|
||
The program is ill-formed if traits::char_type is not the same type as charT[.](#3.sentence-6)
|
||
|
||
â *end note*]
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2394)
|
||
|
||
References, pointers, and iterators referring to the elements of abasic_string sequence may be
|
||
invalidated by the following uses of that basic_string object:
|
||
|
||
- [(4.1)](#4.1)
|
||
|
||
Passing as an argument to any standard library function taking a reference to non-constbasic_string as an argument[.](#4.1.sentence-1)[212](#footnote-212 "For example, as an argument to non-member functions swap() ([string.special]), operator>>() ([string.io]), and getline() ([string.io]), or as an argument to basic_string::swap().")
|
||
|
||
- [(4.2)](#4.2)
|
||
|
||
Calling non-const member functions, exceptoperator[],at,data,front,back,begin,rbegin,end,
|
||
andrend[.](#4.2.sentence-1)
|
||
|
||
[212)](#footnote-212)[212)](#footnoteref-212)
|
||
|
||
For example, as an argument to non-member
|
||
functions swap() ([[string.special]](string.special "27.4.4.3 swap")),operator>>() ([[string.io]](string.io "27.4.4.4 Inserters and extractors")), and getline() ([[string.io]](string.io "27.4.4.4 Inserters and extractors")), or as
|
||
an argument to basic_string::swap()[.](#footnote-212.sentence-1)
|