Init
This commit is contained in:
96
cppdraft/string/access.md
Normal file
96
cppdraft/string/access.md
Normal file
@@ -0,0 +1,96 @@
|
||||
[string.access]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.access)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.access)
|
||||
|
||||
#### 27.4.3.6 Element access [string.access]
|
||||
|
||||
[ð](#lib:operator%5b%5d,basic_string)
|
||||
|
||||
`constexpr const_reference operator[](size_type pos) const;
|
||||
constexpr reference operator[](size_type pos);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3098)
|
||||
|
||||
*Hardened preconditions*: pos <= size() is true[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3102)
|
||||
|
||||
*Returns*: *(begin() + pos) if pos < size()[.](#2.sentence-1)
|
||||
|
||||
Otherwise,
|
||||
returns a reference to an object of type charT with valuecharT(), where modifying the object to any value other thancharT() leads to undefined behavior[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3109)
|
||||
|
||||
*Throws*: Nothing[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3113)
|
||||
|
||||
*Complexity*: Constant time[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:at,basic_string)
|
||||
|
||||
`constexpr const_reference at(size_type pos) const;
|
||||
constexpr reference at(size_type pos);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3125)
|
||||
|
||||
*Returns*: operator[](pos)[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3129)
|
||||
|
||||
*Throws*: out_of_range ifpos >= size()[.](#6.sentence-1)
|
||||
|
||||
[ð](#lib:front,basic_string)
|
||||
|
||||
`constexpr const charT& front() const;
|
||||
constexpr charT& front();
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3143)
|
||||
|
||||
*Hardened preconditions*: empty() is false[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3147)
|
||||
|
||||
*Effects*: Equivalent to: return operator[](0);
|
||||
|
||||
[ð](#lib:back,basic_string)
|
||||
|
||||
`constexpr const charT& back() const;
|
||||
constexpr charT& back();
|
||||
`
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3159)
|
||||
|
||||
*Hardened preconditions*: empty() is false[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3163)
|
||||
|
||||
*Effects*: Equivalent to: return operator[](size() - 1);
|
||||
81
cppdraft/string/accessors.md
Normal file
81
cppdraft/string/accessors.md
Normal file
@@ -0,0 +1,81 @@
|
||||
[string.accessors]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.accessors)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.accessors)
|
||||
|
||||
#### 27.4.3.8 String operations [[string.ops]](string.ops#string.accessors)
|
||||
|
||||
#### 27.4.3.8.1 Accessors [string.accessors]
|
||||
|
||||
[ð](#lib:c_str,basic_string)
|
||||
|
||||
`constexpr const charT* c_str() const noexcept;
|
||||
constexpr const charT* data() const noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4297)
|
||||
|
||||
*Returns*: A pointer p such that p + i == addressof(operator[](i)) for eachi in [0, size()][.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4302)
|
||||
|
||||
*Complexity*: Constant time[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4306)
|
||||
|
||||
*Remarks*: The program shall not modify any of the values stored in the character array; otherwise, the behavior is undefined[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:data,basic_string_)
|
||||
|
||||
`constexpr charT* data() noexcept;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4317)
|
||||
|
||||
*Returns*: A pointer p such that p + i == addressof(operator[](i)) for eachi in [0, size()][.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4322)
|
||||
|
||||
*Complexity*: Constant time[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4326)
|
||||
|
||||
*Remarks*: The program shall not modify the value stored at p + size() to any value other than charT(); otherwise, the behavior is undefined[.](#6.sentence-1)
|
||||
|
||||
[ð](#lib:operator_basic_string_view,basic_string)
|
||||
|
||||
`constexpr operator basic_string_view<charT, traits>() const noexcept;
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4338)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(data(), size());
|
||||
|
||||
[ð](#lib:get_allocator,basic_string)
|
||||
|
||||
`constexpr allocator_type get_allocator() const noexcept;
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4350)
|
||||
|
||||
*Returns*: A copy of theAllocator object used to construct the string or, if that allocator has been replaced, a
|
||||
copy of the most recent replacement[.](#8.sentence-1)
|
||||
189
cppdraft/string/append.md
Normal file
189
cppdraft/string/append.md
Normal file
@@ -0,0 +1,189 @@
|
||||
[string.append]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.append)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.append)
|
||||
|
||||
#### 27.4.3.7 Modifiers [[string.modifiers]](string.modifiers#string.append)
|
||||
|
||||
#### 27.4.3.7.2 basic_string::append [string.append]
|
||||
|
||||
[ð](#lib:append,basic_string)
|
||||
|
||||
`constexpr basic_string& append(const basic_string& str);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3254)
|
||||
|
||||
*Effects*: Equivalent to: return append(str.data(), str.size());
|
||||
|
||||
[ð](#lib:append,basic_string_)
|
||||
|
||||
`constexpr basic_string& append(const basic_string& str, size_type pos, size_type n = npos);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3265)
|
||||
|
||||
*Effects*: Equivalent to:return append(basic_string_view<charT, traits>(str).substr(pos, n));
|
||||
|
||||
[ð](#lib:append,basic_string__)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& append(const T& t);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3280)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3291)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return append(sv.data(), sv.size());
|
||||
|
||||
[ð](#lib:append,basic_string___)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& append(const T& t, size_type pos, size_type n = npos);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3307)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(5.1)](#5.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(5.2)](#5.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3318)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return append(sv.substr(pos, n));
|
||||
|
||||
[ð](#lib:append,basic_string____)
|
||||
|
||||
`constexpr basic_string& append(const charT* s, size_type n);
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3333)
|
||||
|
||||
*Preconditions*: [s, s + n) is a valid range[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3337)
|
||||
|
||||
*Effects*: Appends a copy of the range [s, s + n) to the string[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3341)
|
||||
|
||||
*Returns*: *this[.](#9.sentence-1)
|
||||
|
||||
[ð](#lib:append,basic_string_____)
|
||||
|
||||
`constexpr basic_string& append(const charT* s);
|
||||
`
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3352)
|
||||
|
||||
*Effects*: Equivalent to: return append(s, traits::length(s));
|
||||
|
||||
[ð](#lib:append,basic_string______)
|
||||
|
||||
`constexpr basic_string& append(size_type n, charT c);
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3363)
|
||||
|
||||
*Effects*: Appends n copies of c to the string[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3367)
|
||||
|
||||
*Returns*: *this[.](#12.sentence-1)
|
||||
|
||||
[ð](#lib:append,basic_string_______)
|
||||
|
||||
`template<class InputIterator>
|
||||
constexpr basic_string& append(InputIterator first, InputIterator last);
|
||||
`
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3379)
|
||||
|
||||
*Constraints*: InputIterator is a type that qualifies as an input
|
||||
iterator ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements"))[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3384)
|
||||
|
||||
*Effects*: Equivalent to: return append(basic_string(first, last, get_allocator()));
|
||||
|
||||
[ð](#lib:append_range,basic_string)
|
||||
|
||||
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<charT> R>
|
||||
constexpr basic_string& append_range(R&& rg);
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3396)
|
||||
|
||||
*Effects*: Equivalent to: return append(basic_string(from_range, std::forward<R>(rg), get_allocator()));
|
||||
|
||||
[ð](#lib:append,basic_string________)
|
||||
|
||||
`constexpr basic_string& append(initializer_list<charT> il);
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3407)
|
||||
|
||||
*Effects*: Equivalent to: return append(il.begin(), il.size());
|
||||
|
||||
[ð](#lib:push_back,basic_string)
|
||||
|
||||
`constexpr void push_back(charT c);
|
||||
`
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3418)
|
||||
|
||||
*Effects*: Equivalent toappend(size_type{1}, c)[.](#17.sentence-1)
|
||||
187
cppdraft/string/assign.md
Normal file
187
cppdraft/string/assign.md
Normal file
@@ -0,0 +1,187 @@
|
||||
[string.assign]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.assign)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.assign)
|
||||
|
||||
#### 27.4.3.7 Modifiers [[string.modifiers]](string.modifiers#string.assign)
|
||||
|
||||
#### 27.4.3.7.3 basic_string::assign [string.assign]
|
||||
|
||||
[ð](#lib:assign,basic_string)
|
||||
|
||||
`constexpr basic_string& assign(const basic_string& str);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3432)
|
||||
|
||||
*Effects*: Equivalent to: return *this = str;
|
||||
|
||||
[ð](#lib:assign,basic_string_)
|
||||
|
||||
`constexpr basic_string& assign(basic_string&& str)
|
||||
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
|
||||
allocator_traits<Allocator>::is_always_equal::value);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3445)
|
||||
|
||||
*Effects*: Equivalent to: return *this = std::move(str);
|
||||
|
||||
[ð](#lib:assign,basic_string__)
|
||||
|
||||
`constexpr basic_string& assign(const basic_string& str, size_type pos, size_type n = npos);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3457)
|
||||
|
||||
*Effects*: Equivalent to:return assign(basic_string_view<charT, traits>(str).substr(pos, n));
|
||||
|
||||
[ð](#lib:assign,basic_string___)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& assign(const T& t);
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3472)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3483)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return assign(sv.data(), sv.size());
|
||||
|
||||
[ð](#lib:assign,basic_string____)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& assign(const T& t, size_type pos, size_type n = npos);
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3499)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(6.1)](#6.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(6.2)](#6.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3510)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return assign(sv.substr(pos, n));
|
||||
|
||||
[ð](#lib:assign,basic_string_____)
|
||||
|
||||
`constexpr basic_string& assign(const charT* s, size_type n);
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3525)
|
||||
|
||||
*Preconditions*: [s, s + n) is a valid range[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3529)
|
||||
|
||||
*Effects*: Replaces the string controlled by *this with
|
||||
a copy of the range [s, s + n)[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3534)
|
||||
|
||||
*Returns*: *this[.](#10.sentence-1)
|
||||
|
||||
[ð](#lib:assign,basic_string______)
|
||||
|
||||
`constexpr basic_string& assign(const charT* s);
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3545)
|
||||
|
||||
*Effects*: Equivalent to: return assign(s, traits::length(s));
|
||||
|
||||
[ð](#lib:assign,basic_string_______)
|
||||
|
||||
`constexpr basic_string& assign(initializer_list<charT> il);
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3556)
|
||||
|
||||
*Effects*: Equivalent to: return assign(il.begin(), il.size());
|
||||
|
||||
[ð](#lib:assign,basic_string________)
|
||||
|
||||
`constexpr basic_string& assign(size_type n, charT c);
|
||||
`
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3567)
|
||||
|
||||
*Effects*: Equivalent to:clear();
|
||||
resize(n, c);return *this;
|
||||
|
||||
[ð](#lib:assign,basic_string_________)
|
||||
|
||||
`template<class InputIterator>
|
||||
constexpr basic_string& assign(InputIterator first, InputIterator last);
|
||||
`
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3584)
|
||||
|
||||
*Constraints*: InputIterator is a type that qualifies as an input
|
||||
iterator ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements"))[.](#14.sentence-1)
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3589)
|
||||
|
||||
*Effects*: Equivalent to: return assign(basic_string(first, last, get_allocator()));
|
||||
|
||||
[ð](#lib:assign_range,basic_string)
|
||||
|
||||
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<charT> R>
|
||||
constexpr basic_string& assign_range(R&& rg);
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3601)
|
||||
|
||||
*Effects*: Equivalent to: return assign(basic_string(from_range, std::forward<R>(rg), get_allocator()));
|
||||
261
cppdraft/string/capacity.md
Normal file
261
cppdraft/string/capacity.md
Normal file
@@ -0,0 +1,261 @@
|
||||
[string.capacity]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.capacity)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.capacity)
|
||||
|
||||
#### 27.4.3.5 Capacity [string.capacity]
|
||||
|
||||
[ð](#lib:size,basic_string)
|
||||
|
||||
`constexpr size_type size() const noexcept;
|
||||
constexpr size_type length() const noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2872)
|
||||
|
||||
*Returns*: A count of the number of char-like objects currently in the string[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2876)
|
||||
|
||||
*Complexity*: Constant time[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:max_size,basic_string)
|
||||
|
||||
`constexpr size_type max_size() const noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2887)
|
||||
|
||||
*Returns*: The largest possible number of char-like objects that can be stored in abasic_string[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2892)
|
||||
|
||||
*Complexity*: Constant time[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:resize,basic_string)
|
||||
|
||||
`constexpr void resize(size_type n, charT c);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2903)
|
||||
|
||||
*Effects*: Alters the value of*this as follows:
|
||||
|
||||
- [(5.1)](#5.1)
|
||||
|
||||
Ifn <= size(),
|
||||
erases the last size() - n elements[.](#5.1.sentence-1)
|
||||
|
||||
- [(5.2)](#5.2)
|
||||
|
||||
Ifn > size(),
|
||||
appends n - size() copies of c[.](#5.2.sentence-1)
|
||||
|
||||
[ð](#lib:resize,basic_string_)
|
||||
|
||||
`constexpr void resize(size_type n);
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2926)
|
||||
|
||||
*Effects*: Equivalent to resize(n, charT())[.](#6.sentence-1)
|
||||
|
||||
[ð](#lib:resize_and_overwrite,basic_string)
|
||||
|
||||
`template<class Operation> constexpr void resize_and_overwrite(size_type n, Operation op);
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2937)
|
||||
|
||||
Let
|
||||
|
||||
- [(7.1)](#7.1)
|
||||
|
||||
o = size() before the call to resize_and_overwrite[.](#7.1.sentence-1)
|
||||
|
||||
- [(7.2)](#7.2)
|
||||
|
||||
k be min(o, n)[.](#7.2.sentence-1)
|
||||
|
||||
- [(7.3)](#7.3)
|
||||
|
||||
p be a value of type charT* or charT* const,
|
||||
such that the range [p, p + n] is valid andthis->compare(0, k, p, k) == 0 is true before the call[.](#7.3.sentence-1)
|
||||
The values in the range [p + k, p + n] may be indeterminate ([[basic.indet]](basic.indet "6.8.5 Indeterminate and erroneous values"))[.](#7.3.sentence-2)
|
||||
|
||||
- [(7.4)](#7.4)
|
||||
|
||||
m be a value of type size_type or const size_type equal to n[.](#7.4.sentence-1)
|
||||
|
||||
- [(7.5)](#7.5)
|
||||
|
||||
*OP* be the expression std::move(op)(p, m)[.](#7.5.sentence-1)
|
||||
|
||||
- [(7.6)](#7.6)
|
||||
|
||||
r = *OP*[.](#7.6.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2958)
|
||||
|
||||
*Mandates*: *OP* has an integer-like type ([[iterator.concept.winc]](iterator.concept.winc "24.3.4.4 Concept weakly_incrementable"))[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2962)
|
||||
|
||||
*Preconditions*:
|
||||
|
||||
- [(9.1)](#9.1)
|
||||
|
||||
*OP* does not throw an exception or modify p or m[.](#9.1.sentence-1)
|
||||
|
||||
- [(9.2)](#9.2)
|
||||
|
||||
r ⥠0[.](#9.2.sentence-1)
|
||||
|
||||
- [(9.3)](#9.3)
|
||||
|
||||
r ⤠m[.](#9.3.sentence-1)
|
||||
|
||||
- [(9.4)](#9.4)
|
||||
|
||||
After evaluating *OP* there are no indeterminate values in the range [p, p + r)[.](#9.4.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2976)
|
||||
|
||||
*Effects*: Evaluates *OP*,
|
||||
replaces the contents of *this with [p, p + r), and
|
||||
invalidates all pointers and references to the range [p, p + n][.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2982)
|
||||
|
||||
*Recommended practice*: Implementations should avoid unnecessary copies and allocations
|
||||
by, for example, making p a pointer into internal storage and
|
||||
by restoring *(p + r) to charT() after evaluating *OP*[.](#11.sentence-1)
|
||||
|
||||
[ð](#lib:capacity,basic_string)
|
||||
|
||||
`constexpr size_type capacity() const noexcept;
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2995)
|
||||
|
||||
*Returns*: The size of the allocated storage in the string[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2999)
|
||||
|
||||
*Complexity*: Constant time[.](#13.sentence-1)
|
||||
|
||||
[ð](#lib:reserve,basic_string)
|
||||
|
||||
`constexpr void reserve(size_type res_arg);
|
||||
`
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3010)
|
||||
|
||||
*Effects*: A directive that informs a basic_string of a planned change in size,
|
||||
so that the storage allocation can be managed accordingly[.](#14.sentence-1)
|
||||
|
||||
Following a call toreserve,capacity() is greater or equal to the argument ofreserve if reallocation happens; and
|
||||
equal to the previous value ofcapacity() otherwise[.](#14.sentence-2)
|
||||
|
||||
Reallocation happens at this point if and only if
|
||||
the current capacity is less than the argument of reserve[.](#14.sentence-3)
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3026)
|
||||
|
||||
*Throws*: length_error ifres_arg > max_size() or any exceptions thrown byallocator_traits <Allocator>::allocate[.](#15.sentence-1)
|
||||
|
||||
[ð](#lib:shrink_to_fit,basic_string)
|
||||
|
||||
`constexpr void shrink_to_fit();
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3040)
|
||||
|
||||
*Effects*: shrink_to_fit is a non-binding request to reducecapacity() to size()[.](#16.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The request is non-binding to
|
||||
allow latitude for implementation-specific optimizations[.](#16.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
It does not increase capacity(), but may reduce capacity() by causing reallocation[.](#16.sentence-3)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3051)
|
||||
|
||||
*Complexity*: If the size is not equal to the old capacity,
|
||||
linear in the size of the sequence;
|
||||
otherwise constant[.](#17.sentence-1)
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3057)
|
||||
|
||||
*Remarks*: Reallocation invalidates all the references, pointers, and iterators
|
||||
referring to the elements in the sequence, as well as the past-the-end iterator[.](#18.sentence-1)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
If no reallocation happens, they remain valid[.](#18.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[ð](#lib:clear,basic_string)
|
||||
|
||||
`constexpr void clear() noexcept;
|
||||
`
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3072)
|
||||
|
||||
*Effects*: Equivalent to: erase(begin(), end());
|
||||
|
||||
[ð](#lib:empty,basic_string)
|
||||
|
||||
`constexpr bool empty() const noexcept;
|
||||
`
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3083)
|
||||
|
||||
*Effects*: Equivalent to:return size() == 0;
|
||||
3295
cppdraft/string/classes.md
Normal file
3295
cppdraft/string/classes.md
Normal file
File diff suppressed because it is too large
Load Diff
17
cppdraft/string/classes/general.md
Normal file
17
cppdraft/string/classes/general.md
Normal file
@@ -0,0 +1,17 @@
|
||||
[string.classes.general]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#general)
|
||||
|
||||
### 27.4.1 General [string.classes.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1754)
|
||||
|
||||
The header <string> defines thebasic_string class template for manipulating
|
||||
varying-length sequences of char-like objects and five[*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]")*s*, string,u8string,u16string,u32string,
|
||||
and wstring, that name
|
||||
the specializationsbasic_string<char>,basic_string<char8_t>,basic_string<char16_t>,basic_string<char32_t>,
|
||||
andbasic_string<wchar_t>, respectively[.](#1.sentence-1)
|
||||
35
cppdraft/string/cmp.md
Normal file
35
cppdraft/string/cmp.md
Normal file
@@ -0,0 +1,35 @@
|
||||
[string.cmp]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.cmp)
|
||||
|
||||
### 27.4.4 Non-member functions [[string.nonmembers]](string.nonmembers#string.cmp)
|
||||
|
||||
#### 27.4.4.2 Non-member comparison operator functions [string.cmp]
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr bool
|
||||
operator==(const basic_string<charT, traits, Allocator>& lhs,
|
||||
const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr bool operator==(const basic_string<charT, traits, Allocator>& lhs,
|
||||
const charT* rhs);
|
||||
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,
|
||||
const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,
|
||||
const charT* rhs);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4980)
|
||||
|
||||
*Effects*: Let *op* be the operator[.](#1.sentence-1)
|
||||
|
||||
Equivalent to:return basic_string_view<charT, traits>(lhs) *op* basic_string_view<charT, traits>(rhs);
|
||||
163
cppdraft/string/compare.md
Normal file
163
cppdraft/string/compare.md
Normal file
@@ -0,0 +1,163 @@
|
||||
[string.compare]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.compare)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.compare)
|
||||
|
||||
#### 27.4.3.8 String operations [[string.ops]](string.ops#string.compare)
|
||||
|
||||
#### 27.4.3.8.4 basic_string::compare [string.compare]
|
||||
|
||||
[ð](#lib:compare,basic_string)
|
||||
|
||||
`template<class T>
|
||||
constexpr int compare(const T& t) const noexcept(see below);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4499)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4510)
|
||||
|
||||
*Effects*: Equivalent to: return basic_string_view<charT, traits>(*this).compare(t);
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4514)
|
||||
|
||||
*Remarks*: The exception specification is equivalent tois_nothrow_convertible_v<const T&, basic_string_view<charT, traits>>[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:compare,basic_string_)
|
||||
|
||||
`template<class T>
|
||||
constexpr int compare(size_type pos1, size_type n1, const T& t) const;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4527)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4538)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(*this).substr(pos1, n1).compare(t);
|
||||
|
||||
[ð](#lib:compare,basic_string__)
|
||||
|
||||
`template<class T>
|
||||
constexpr int compare(size_type pos1, size_type n1, const T& t,
|
||||
size_type pos2, size_type n2 = npos) const;
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4554)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(6.1)](#6.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(6.2)](#6.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4565)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> s = *this, sv = t;return s.substr(pos1, n1).compare(sv.substr(pos2, n2));
|
||||
|
||||
[ð](#lib:compare,basic_string___)
|
||||
|
||||
`constexpr int compare(const basic_string& str) const noexcept;
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4580)
|
||||
|
||||
*Effects*: Equivalent to:return compare(basic_string_view<charT, traits>(str));
|
||||
|
||||
[ð](#lib:compare,basic_string____)
|
||||
|
||||
`constexpr int compare(size_type pos1, size_type n1, const basic_string& str) const;
|
||||
`
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4592)
|
||||
|
||||
*Effects*: Equivalent to:return compare(pos1, n1, basic_string_view<charT, traits>(str));
|
||||
|
||||
[ð](#lib:compare,basic_string_____)
|
||||
|
||||
`constexpr int compare(size_type pos1, size_type n1, const basic_string& str,
|
||||
size_type pos2, size_type n2 = npos) const;
|
||||
`
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4605)
|
||||
|
||||
*Effects*: Equivalent to:return compare(pos1, n1, basic_string_view<charT, traits>(str), pos2, n2);
|
||||
|
||||
[ð](#lib:compare,basic_string______)
|
||||
|
||||
`constexpr int compare(const charT* s) const;
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4619)
|
||||
|
||||
*Effects*: Equivalent to:return compare(basic_string_view<charT, traits>(s));
|
||||
|
||||
[ð](#lib:compare,basic_string_______)
|
||||
|
||||
`constexpr int compare(size_type pos, size_type n1, const charT* s) const;
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4631)
|
||||
|
||||
*Effects*: Equivalent to: return compare(pos, n1, basic_string_view<charT, traits>(s));
|
||||
|
||||
[ð](#lib:compare,basic_string________)
|
||||
|
||||
`constexpr int compare(size_type pos, size_type n1, const charT* s, size_type n2) const;
|
||||
`
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4642)
|
||||
|
||||
*Effects*: Equivalent to: return compare(pos, n1, basic_string_view<charT, traits>(s, n2));
|
||||
415
cppdraft/string/cons.md
Normal file
415
cppdraft/string/cons.md
Normal file
@@ -0,0 +1,415 @@
|
||||
[string.cons]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.cons)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.cons)
|
||||
|
||||
#### 27.4.3.3 Constructors and assignment operators [string.cons]
|
||||
|
||||
[ð](#lib:basic_string,constructor)
|
||||
|
||||
`constexpr explicit basic_string(const Allocator& a) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2431)
|
||||
|
||||
*Postconditions*: size() is equal to 0[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string,constructor_)
|
||||
|
||||
`constexpr basic_string(const basic_string& str);
|
||||
constexpr basic_string(basic_string&& str) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2443)
|
||||
|
||||
*Effects*: Constructs an object whose
|
||||
value is that of str prior to this call[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2448)
|
||||
|
||||
*Remarks*: In the second form, str is left in a valid but unspecified state[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string,constructor__)
|
||||
|
||||
`constexpr basic_string(const basic_string& str, size_type pos,
|
||||
const Allocator& a = Allocator());
|
||||
constexpr basic_string(const basic_string& str, size_type pos, size_type n,
|
||||
const Allocator& a = Allocator());
|
||||
constexpr basic_string(basic_string&& str, size_type pos,
|
||||
const Allocator& a = Allocator());
|
||||
constexpr basic_string(basic_string&& str, size_type pos, size_type n,
|
||||
const Allocator& a = Allocator());
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2466)
|
||||
|
||||
Let
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
s be the value of str prior to this call and
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
rlen be pos + min(n, s.size() - pos) for the overloads with parameter n, ands.size() otherwise[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2477)
|
||||
|
||||
*Effects*: Constructs an object
|
||||
whose initial value is the range [s.data() + pos, s.data() + rlen)[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2482)
|
||||
|
||||
*Throws*: out_of_range if pos > s.size()[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2486)
|
||||
|
||||
*Remarks*: For the overloads with a basic_string&& parameter,str is left in a valid but unspecified state[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2491)
|
||||
|
||||
*Recommended practice*: For the overloads with a basic_string&& parameter,
|
||||
implementations should avoid allocation
|
||||
if s.get_allocator() == a is true[.](#8.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string,constructor___)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator());
|
||||
`
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2505)
|
||||
|
||||
*Constraints*: is_convertible_v<const T&, basic_string_view<charT, traits>> is true[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2510)
|
||||
|
||||
*Effects*: Creates a variable, sv,
|
||||
as if by basic_string_view<charT, traits> sv = t; and then behaves the same as:basic_string(sv.substr(pos, n), a);
|
||||
|
||||
[ð](#lib:basic_string,constructor____)
|
||||
|
||||
`template<class T>
|
||||
constexpr explicit basic_string(const T& t, const Allocator& a = Allocator());
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2527)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(11.1)](#11.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(11.2)](#11.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2538)
|
||||
|
||||
*Effects*: Creates a variable, sv, as if bybasic_string_view<charT, traits> sv = t; and
|
||||
then behaves the same as basic_string(sv.data(), sv.size(), a)[.](#12.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string,constructor_____)
|
||||
|
||||
`constexpr basic_string(const charT* s, size_type n, const Allocator& a = Allocator());
|
||||
`
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2551)
|
||||
|
||||
*Preconditions*: [s, s + n) is a valid range[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2555)
|
||||
|
||||
*Effects*: Constructs an object whose initial value is the range [s, s + n)[.](#14.sentence-1)
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2559)
|
||||
|
||||
*Postconditions*: size() is equal to n, andtraits::compare(data(), s, n) is equal to 0[.](#15.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string,constructor______)
|
||||
|
||||
`constexpr basic_string(const charT* s, const Allocator& a = Allocator());
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2571)
|
||||
|
||||
*Constraints*: Allocator is a type
|
||||
that qualifies as an allocator ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements"))[.](#16.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
This affects class template argument deduction[.](#16.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2579)
|
||||
|
||||
*Effects*: Equivalent to: basic_string(s, traits::length(s), a)[.](#17.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string,constructor_______)
|
||||
|
||||
`constexpr basic_string(size_type n, charT c, const Allocator& a = Allocator());
|
||||
`
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2590)
|
||||
|
||||
*Constraints*: Allocator is a type
|
||||
that qualifies as an allocator ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements"))[.](#18.sentence-1)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
This affects class template argument deduction[.](#18.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2598)
|
||||
|
||||
*Effects*: Constructs an object whose value consists of n copies of c[.](#19.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string,constructor________)
|
||||
|
||||
`template<class InputIterator>
|
||||
constexpr basic_string(InputIterator begin, InputIterator end, const Allocator& a = Allocator());
|
||||
`
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2610)
|
||||
|
||||
*Constraints*: InputIterator is a type that qualifies as an input
|
||||
iterator ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements"))[.](#20.sentence-1)
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2615)
|
||||
|
||||
*Effects*: Constructs a string from the values in the range [begin, end),
|
||||
as specified in [[sequence.reqmts]](sequence.reqmts "23.2.4 Sequence containers")[.](#21.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string,constructor_________)
|
||||
|
||||
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<charT> R>
|
||||
constexpr basic_string(from_range_t, R&& rg, const Allocator& = Allocator());
|
||||
`
|
||||
|
||||
[22](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2628)
|
||||
|
||||
*Effects*: Constructs a string from the values in the range rg,
|
||||
as specified in [[sequence.reqmts]](sequence.reqmts "23.2.4 Sequence containers")[.](#22.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string,constructor__________)
|
||||
|
||||
`constexpr basic_string(initializer_list<charT> il, const Allocator& a = Allocator());
|
||||
`
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2640)
|
||||
|
||||
*Effects*: Equivalent to basic_string(il.begin(), il.end(), a)[.](#23.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string,constructor___________)
|
||||
|
||||
`constexpr basic_string(const basic_string& str, const Allocator& alloc);
|
||||
constexpr basic_string(basic_string&& str, const Allocator& alloc);
|
||||
`
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2652)
|
||||
|
||||
*Effects*: Constructs an object whose value is
|
||||
that of str prior to this call[.](#24.sentence-1)
|
||||
|
||||
The stored allocator is constructed from alloc[.](#24.sentence-2)
|
||||
|
||||
In the second form, str is left in a valid but unspecified state[.](#24.sentence-3)
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2659)
|
||||
|
||||
*Throws*: The second form throws nothing if alloc == str.get_allocator()[.](#25.sentence-1)
|
||||
|
||||
[ð](#itemdecl:13)
|
||||
|
||||
`template<class InputIterator,
|
||||
class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>>
|
||||
basic_string(InputIterator, InputIterator, Allocator = Allocator())
|
||||
-> basic_string<typename iterator_traits<InputIterator>::value_type,
|
||||
char_traits<typename iterator_traits<InputIterator>::value_type>,
|
||||
Allocator>;
|
||||
`
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2674)
|
||||
|
||||
*Constraints*: InputIterator is a type that qualifies as an input iterator,
|
||||
and Allocator is a type that qualifies as an allocator ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements"))[.](#26.sentence-1)
|
||||
|
||||
[ð](#itemdecl:14)
|
||||
|
||||
`template<class charT,
|
||||
class traits,
|
||||
class Allocator = allocator<charT>>
|
||||
explicit basic_string(basic_string_view<charT, traits>, const Allocator& = Allocator())
|
||||
-> basic_string<charT, traits, Allocator>;
|
||||
|
||||
template<class charT,
|
||||
class traits,
|
||||
class Allocator = allocator<charT>>
|
||||
basic_string(basic_string_view<charT, traits>,
|
||||
typename see below::size_type, typename see below::size_type,
|
||||
const Allocator& = Allocator())
|
||||
-> basic_string<charT, traits, Allocator>;
|
||||
`
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2697)
|
||||
|
||||
*Constraints*: Allocator is a type that qualifies as
|
||||
an allocator ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements"))[.](#27.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,basic_string)
|
||||
|
||||
`constexpr basic_string& operator=(const basic_string& str);
|
||||
`
|
||||
|
||||
[28](#28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2709)
|
||||
|
||||
*Effects*: If *this and str are the same object, has no effect[.](#28.sentence-1)
|
||||
|
||||
Otherwise, replaces the value of *this with a copy of str[.](#28.sentence-2)
|
||||
|
||||
[29](#29)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2714)
|
||||
|
||||
*Returns*: *this[.](#29.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,basic_string_)
|
||||
|
||||
`constexpr basic_string& operator=(basic_string&& str)
|
||||
noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
|
||||
allocator_traits<Allocator>::is_always_equal::value);
|
||||
`
|
||||
|
||||
[30](#30)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2727)
|
||||
|
||||
*Effects*: Move assigns as a sequence container ([[sequence.reqmts]](sequence.reqmts "23.2.4 Sequence containers")),
|
||||
except that iterators, pointers and references may be invalidated[.](#30.sentence-1)
|
||||
|
||||
[31](#31)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2732)
|
||||
|
||||
*Returns*: *this[.](#31.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,basic_string__)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& operator=(const T& t);
|
||||
`
|
||||
|
||||
[32](#32)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2744)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(32.1)](#32.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> is true and
|
||||
|
||||
- [(32.2)](#32.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> is false[.](#32.sentence-1)
|
||||
|
||||
[33](#33)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2753)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return assign(sv);
|
||||
|
||||
[ð](#lib:operator=,basic_string___)
|
||||
|
||||
`constexpr basic_string& operator=(const charT* s);
|
||||
`
|
||||
|
||||
[34](#34)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2768)
|
||||
|
||||
*Effects*: Equivalent to:return *this = basic_string_view<charT, traits>(s);
|
||||
|
||||
[ð](#lib:operator=,basic_string____)
|
||||
|
||||
`constexpr basic_string& operator=(charT c);
|
||||
`
|
||||
|
||||
[35](#35)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2780)
|
||||
|
||||
*Effects*: Equivalent to:return *this = basic_string_view<charT, traits>(addressof(c), 1);
|
||||
|
||||
[ð](#lib:operator=,basic_string_____)
|
||||
|
||||
`constexpr basic_string& operator=(initializer_list<charT> il);
|
||||
`
|
||||
|
||||
[36](#36)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2794)
|
||||
|
||||
*Effects*: Equivalent to:return *this = basic_string_view<charT, traits>(il.begin(), il.size());
|
||||
24
cppdraft/string/contains.md
Normal file
24
cppdraft/string/contains.md
Normal file
@@ -0,0 +1,24 @@
|
||||
[string.contains]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.contains)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.contains)
|
||||
|
||||
#### 27.4.3.8 String operations [[string.ops]](string.ops#string.contains)
|
||||
|
||||
#### 27.4.3.8.7 basic_string::contains [string.contains]
|
||||
|
||||
[ð](#lib:contains,basic_string)
|
||||
|
||||
`constexpr bool contains(basic_string_view<charT, traits> x) const noexcept;
|
||||
constexpr bool contains(charT x) const noexcept;
|
||||
constexpr bool contains(const charT* x) const;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4693)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(data(), size()).contains(x);
|
||||
205
cppdraft/string/conversions.md
Normal file
205
cppdraft/string/conversions.md
Normal file
@@ -0,0 +1,205 @@
|
||||
[string.conversions]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.conversions)
|
||||
|
||||
### 27.4.5 Numeric conversions [string.conversions]
|
||||
|
||||
[ð](#lib:stoi)
|
||||
|
||||
`int stoi(const string& str, size_t* idx = nullptr, int base = 10);
|
||||
long stol(const string& str, size_t* idx = nullptr, int base = 10);
|
||||
unsigned long stoul(const string& str, size_t* idx = nullptr, int base = 10);
|
||||
long long stoll(const string& str, size_t* idx = nullptr, int base = 10);
|
||||
unsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5214)
|
||||
|
||||
*Effects*: The first two functions call strtol(str.c_str(), ptr, base),
|
||||
and the last three functions call strtoul(str.c_str(), ptr, base),strtoll(str.c_str(), ptr, base), and strtoull(str.c_str(), ptr,
|
||||
base), respectively[.](#1.sentence-1)
|
||||
|
||||
Each function returns the converted result, if any[.](#1.sentence-2)
|
||||
|
||||
The
|
||||
argument ptr designates a pointer to an object internal to the function
|
||||
that is used to determine what to store at *idx[.](#1.sentence-3)
|
||||
|
||||
If the function does
|
||||
not throw an exception and idx != nullptr, the function stores in *idx the index of the first unconverted element of str[.](#1.sentence-4)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5225)
|
||||
|
||||
*Returns*: The converted result[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5229)
|
||||
|
||||
*Throws*: invalid_argument if strtol, strtoul,strtoll, or strtoull reports that no conversion can be
|
||||
performed[.](#3.sentence-1)
|
||||
|
||||
Throws out_of_range if strtol, strtoul,strtoll or strtoull sets errno to ERANGE,
|
||||
or if the converted value is outside the range of representable values
|
||||
for the return type[.](#3.sentence-2)
|
||||
|
||||
[ð](#lib:stof)
|
||||
|
||||
`float stof(const string& str, size_t* idx = nullptr);
|
||||
double stod(const string& str, size_t* idx = nullptr);
|
||||
long double stold(const string& str, size_t* idx = nullptr);
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5249)
|
||||
|
||||
*Effects*: These functions callstrtof(str.c_str(), ptr), strtod(str.c_str(), ptr), andstrtold(str.c_str(), ptr), respectively[.](#4.sentence-1)
|
||||
|
||||
Each function returns
|
||||
the converted result, if any[.](#4.sentence-2)
|
||||
|
||||
The argument ptr designates a pointer to
|
||||
an object internal to the function that is used to determine what to store at*idx[.](#4.sentence-3)
|
||||
|
||||
If the function does not throw an exception and idx != nullptr,
|
||||
the function stores in *idx the index of the first unconverted element
|
||||
of str[.](#4.sentence-4)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5260)
|
||||
|
||||
*Returns*: The converted result[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5264)
|
||||
|
||||
*Throws*: invalid_argument if strtof, strtod, orstrtold reports that no conversion can be performed[.](#6.sentence-1)
|
||||
|
||||
Throwsout_of_range if strtof, strtod, orstrtold sets errno to ERANGE or if the converted value is outside the range of representable
|
||||
values for the return type[.](#6.sentence-2)
|
||||
|
||||
[ð](#lib:to_string)
|
||||
|
||||
`string to_string(int val);
|
||||
string to_string(unsigned val);
|
||||
string to_string(long val);
|
||||
string to_string(unsigned long val);
|
||||
string to_string(long long val);
|
||||
string to_string(unsigned long long val);
|
||||
string to_string(float val);
|
||||
string to_string(double val);
|
||||
string to_string(long double val);
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5288)
|
||||
|
||||
*Returns*: format("{}", val)[.](#7.sentence-1)
|
||||
|
||||
[ð](#lib:stoi_)
|
||||
|
||||
`int stoi(const wstring& str, size_t* idx = nullptr, int base = 10);
|
||||
long stol(const wstring& str, size_t* idx = nullptr, int base = 10);
|
||||
unsigned long stoul(const wstring& str, size_t* idx = nullptr, int base = 10);
|
||||
long long stoll(const wstring& str, size_t* idx = nullptr, int base = 10);
|
||||
unsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10);
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5307)
|
||||
|
||||
*Effects*: The first two functions call wcstol(str.c_str(), ptr, base),
|
||||
and the last three functions call wcstoul(str.c_str(), ptr, base),wcstoll(str.c_str(), ptr, base), and wcstoull(str.c_str(), ptr,
|
||||
base), respectively[.](#8.sentence-1)
|
||||
|
||||
Each function returns the converted result, if any[.](#8.sentence-2)
|
||||
|
||||
The
|
||||
argument ptr designates a pointer to an object internal to the function
|
||||
that is used to determine what to store at *idx[.](#8.sentence-3)
|
||||
|
||||
If the function does
|
||||
not throw an exception and idx != nullptr, the function stores in *idx the index of the first unconverted element of str[.](#8.sentence-4)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5318)
|
||||
|
||||
*Returns*: The converted result[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5322)
|
||||
|
||||
*Throws*: invalid_argument if wcstol, wcstoul, wcstoll, orwcstoull reports that no conversion can be performed[.](#10.sentence-1)
|
||||
|
||||
Throwsout_of_range if the converted value is outside the range of representable values
|
||||
for the return type[.](#10.sentence-2)
|
||||
|
||||
[ð](#lib:stof_)
|
||||
|
||||
`float stof(const wstring& str, size_t* idx = nullptr);
|
||||
double stod(const wstring& str, size_t* idx = nullptr);
|
||||
long double stold(const wstring& str, size_t* idx = nullptr);
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5340)
|
||||
|
||||
*Effects*: These functions call wcstof(str.c_str(), ptr),wcstod(str.c_str(), ptr), and wcstold(str.c_str(), ptr),
|
||||
respectively[.](#11.sentence-1)
|
||||
|
||||
Each function returns the converted
|
||||
result, if any[.](#11.sentence-2)
|
||||
|
||||
The argument ptr designates a pointer to an object internal to
|
||||
the function that is used to determine what to store at *idx[.](#11.sentence-3)
|
||||
|
||||
If the function
|
||||
does not throw an exception and idx != nullptr, the function stores in *idx the index of the first unconverted element of str[.](#11.sentence-4)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5350)
|
||||
|
||||
*Returns*: The converted result[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5354)
|
||||
|
||||
*Throws*: invalid_argument if wcstof, wcstod, or wcstold reports that no
|
||||
conversion can be performed[.](#13.sentence-1)
|
||||
|
||||
Throws out_of_range if wcstof, wcstod, orwcstold sets errno to ERANGE[.](#13.sentence-2)
|
||||
|
||||
[ð](#lib:to_wstring)
|
||||
|
||||
`wstring to_wstring(int val);
|
||||
wstring to_wstring(unsigned val);
|
||||
wstring to_wstring(long val);
|
||||
wstring to_wstring(unsigned long val);
|
||||
wstring to_wstring(long long val);
|
||||
wstring to_wstring(unsigned long long val);
|
||||
wstring to_wstring(float val);
|
||||
wstring to_wstring(double val);
|
||||
wstring to_wstring(long double val);
|
||||
`
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5375)
|
||||
|
||||
*Returns*: format(L"{}", val)[.](#14.sentence-1)
|
||||
28
cppdraft/string/copy.md
Normal file
28
cppdraft/string/copy.md
Normal file
@@ -0,0 +1,28 @@
|
||||
[string.copy]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.copy)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.copy)
|
||||
|
||||
#### 27.4.3.7 Modifiers [[string.modifiers]](string.modifiers#string.copy)
|
||||
|
||||
#### 27.4.3.7.7 basic_string::copy [string.copy]
|
||||
|
||||
[ð](#lib:copy,basic_string)
|
||||
|
||||
`constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4244)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(*this).copy(s, n, pos);
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
This does not terminate s with a null object[.](#1.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
24
cppdraft/string/ends/with.md
Normal file
24
cppdraft/string/ends/with.md
Normal file
@@ -0,0 +1,24 @@
|
||||
[string.ends.with]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.ends.with)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.ends.with)
|
||||
|
||||
#### 27.4.3.8 String operations [[string.ops]](string.ops#string.ends.with)
|
||||
|
||||
#### 27.4.3.8.6 basic_string::ends_with [string.ends.with]
|
||||
|
||||
[ð](#lib:ends_with,basic_string)
|
||||
|
||||
`constexpr bool ends_with(basic_string_view<charT, traits> x) const noexcept;
|
||||
constexpr bool ends_with(charT x) const noexcept;
|
||||
constexpr bool ends_with(const charT* x) const;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4675)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(data(), size()).ends_with(x);
|
||||
126
cppdraft/string/erase.md
Normal file
126
cppdraft/string/erase.md
Normal file
@@ -0,0 +1,126 @@
|
||||
[string.erase]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.erase)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.erase)
|
||||
|
||||
#### 27.4.3.7 Modifiers [[string.modifiers]](string.modifiers#string.erase)
|
||||
|
||||
#### 27.4.3.7.5 basic_string::erase [string.erase]
|
||||
|
||||
[ð](#lib:erase,basic_string)
|
||||
|
||||
`constexpr basic_string& erase(size_type pos = 0, size_type n = npos);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3864)
|
||||
|
||||
*Effects*: Determines the effective length xlen of the string to be removed as the smaller of n andsize() - pos[.](#1.sentence-1)
|
||||
|
||||
Removes the characters in the range [begin() + pos, begin() + pos + xlen)[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3871)
|
||||
|
||||
*Returns*: *this[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3875)
|
||||
|
||||
*Throws*: out_of_range if pos> size()[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:erase,basic_string_)
|
||||
|
||||
`constexpr iterator erase(const_iterator p);
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3888)
|
||||
|
||||
*Preconditions*: p is a valid dereferenceable iterator on *this[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3892)
|
||||
|
||||
*Effects*: Removes the character referred to by p[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3896)
|
||||
|
||||
*Returns*: An iterator which points to the element immediately following p prior to
|
||||
the element being erased[.](#6.sentence-1)
|
||||
|
||||
If no such element exists,end() is returned[.](#6.sentence-2)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3904)
|
||||
|
||||
*Throws*: Nothing[.](#7.sentence-1)
|
||||
|
||||
[ð](#lib:erase,basic_string__)
|
||||
|
||||
`constexpr iterator erase(const_iterator first, const_iterator last);
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3915)
|
||||
|
||||
*Preconditions*: first and last are valid iterators on*this[.](#8.sentence-1)
|
||||
|
||||
[first, last) is a valid range[.](#8.sentence-2)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3920)
|
||||
|
||||
*Effects*: Removes the characters in the range
|
||||
[first, last)[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3925)
|
||||
|
||||
*Returns*: An iterator which points to the element pointed to by last prior to
|
||||
the other elements being erased[.](#10.sentence-1)
|
||||
|
||||
If no such element exists,end() is returned[.](#10.sentence-2)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3933)
|
||||
|
||||
*Throws*: Nothing[.](#11.sentence-1)
|
||||
|
||||
[ð](#lib:pop_back,basic_string)
|
||||
|
||||
`constexpr void pop_back();
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3944)
|
||||
|
||||
*Hardened preconditions*: empty() is false[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3948)
|
||||
|
||||
*Effects*: Equivalent to erase(end() - 1)[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3952)
|
||||
|
||||
*Throws*: Nothing[.](#14.sentence-1)
|
||||
37
cppdraft/string/erasure.md
Normal file
37
cppdraft/string/erasure.md
Normal file
@@ -0,0 +1,37 @@
|
||||
[string.erasure]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.erasure)
|
||||
|
||||
### 27.4.4 Non-member functions [[string.nonmembers]](string.nonmembers#string.erasure)
|
||||
|
||||
#### 27.4.4.5 Erasure [string.erasure]
|
||||
|
||||
[ð](#lib:erase,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator, class U = charT>
|
||||
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
||||
erase(basic_string<charT, traits, Allocator>& c, const U& value);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5168)
|
||||
|
||||
*Effects*: Equivalent to:auto it = remove(c.begin(), c.end(), value);auto r = distance(it, c.end());
|
||||
c.erase(it, c.end());return r;
|
||||
|
||||
[ð](#lib:erase_if,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator, class Predicate>
|
||||
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
||||
erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5187)
|
||||
|
||||
*Effects*: Equivalent to:auto it = remove_if(c.begin(), c.end(), pred);auto r = distance(it, c.end());
|
||||
c.erase(it, c.end());return r;
|
||||
77
cppdraft/string/find.md
Normal file
77
cppdraft/string/find.md
Normal file
@@ -0,0 +1,77 @@
|
||||
[string.find]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.find)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.find)
|
||||
|
||||
#### 27.4.3.8 String operations [[string.ops]](string.ops#string.find)
|
||||
|
||||
#### 27.4.3.8.2 Searching [string.find]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4360)
|
||||
|
||||
Let *F* be one offind, rfind, find_first_of, find_last_of,find_first_not_of, and find_last_not_of[.](#1.sentence-1)
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
Each member function of the formconstexpr size_type *F*(const basic_string& str, size_type pos) const noexcept; has effects equivalent to:return *F*(basic_string_view<charT, traits>(str), pos);
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
Each member function of the formconstexpr size_type *F*(const charT* s, size_type pos) const; has effects equivalent to:return *F*(basic_string_view<charT, traits>(s), pos);
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
Each member function of the formconstexpr size_type *F*(const charT* s, size_type pos, size_type n) const; has effects equivalent to:return *F*(basic_string_view<charT, traits>(s, n), pos);
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
Each member function of the formconstexpr size_type *F*(charT c, size_type pos) const noexcept; has effects equivalent to:return *F*(basic_string_view<charT, traits>(addressof(c), 1), pos);
|
||||
|
||||
[ð](#lib:find,basic_string_)
|
||||
|
||||
`template<class T>
|
||||
constexpr size_type find(const T& t, size_type pos = 0) const noexcept(see below);
|
||||
template<class T>
|
||||
constexpr size_type rfind(const T& t, size_type pos = npos) const noexcept(see below);
|
||||
template<class T>
|
||||
constexpr size_type find_first_of(const T& t, size_type pos = 0) const noexcept(see below);
|
||||
template<class T>
|
||||
constexpr size_type find_last_of(const T& t, size_type pos = npos) const noexcept(see below);
|
||||
template<class T>
|
||||
constexpr size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept(see below);
|
||||
template<class T>
|
||||
constexpr size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept(see below);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4429)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(2.1)](#2.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(2.2)](#2.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4440)
|
||||
|
||||
*Effects*: Let *G* be the name of the function[.](#3.sentence-1)
|
||||
|
||||
Equivalent to:basic_string_view<charT, traits> s = *this, sv = t;return s.*G*(sv, pos);
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4449)
|
||||
|
||||
*Remarks*: The exception specification is equivalent tois_nothrow_convertible_v<const T&, basic_string_view<charT, traits>>[.](#4.sentence-1)
|
||||
289
cppdraft/string/insert.md
Normal file
289
cppdraft/string/insert.md
Normal file
@@ -0,0 +1,289 @@
|
||||
[string.insert]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.insert)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.insert)
|
||||
|
||||
#### 27.4.3.7 Modifiers [[string.modifiers]](string.modifiers#string.insert)
|
||||
|
||||
#### 27.4.3.7.4 basic_string::insert [string.insert]
|
||||
|
||||
[ð](#lib:insert,basic_string)
|
||||
|
||||
`constexpr basic_string& insert(size_type pos, const basic_string& str);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3614)
|
||||
|
||||
*Effects*: Equivalent to: return insert(pos, str.data(), str.size());
|
||||
|
||||
[ð](#lib:insert,basic_string_)
|
||||
|
||||
`constexpr basic_string& insert(size_type pos1, const basic_string& str,
|
||||
size_type pos2, size_type n = npos);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3626)
|
||||
|
||||
*Effects*: Equivalent to:return insert(pos1, basic_string_view<charT, traits>(str), pos2, n);
|
||||
|
||||
[ð](#lib:insert,basic_string__)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& insert(size_type pos, const T& t);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3641)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3652)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return insert(pos, sv.data(), sv.size());
|
||||
|
||||
[ð](#lib:insert,basic_string___)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& insert(size_type pos1, const T& t,
|
||||
size_type pos2, size_type n = npos);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3669)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(5.1)](#5.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(5.2)](#5.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3680)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return insert(pos1, sv.substr(pos2, n));
|
||||
|
||||
[ð](#lib:insert,basic_string____)
|
||||
|
||||
`constexpr basic_string& insert(size_type pos, const charT* s, size_type n);
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3695)
|
||||
|
||||
*Preconditions*: [s, s + n) is a valid range[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3699)
|
||||
|
||||
*Effects*: Inserts a copy of the range [s, s + n)
|
||||
immediately before the character at position pos if pos < size(),
|
||||
or otherwise at the end of the string[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3705)
|
||||
|
||||
*Returns*: *this[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3709)
|
||||
|
||||
*Throws*:
|
||||
|
||||
- [(10.1)](#10.1)
|
||||
|
||||
out_of_range if pos > size(),
|
||||
|
||||
- [(10.2)](#10.2)
|
||||
|
||||
length_error if n > max_size() - size(), or
|
||||
|
||||
- [(10.3)](#10.3)
|
||||
|
||||
any exceptions thrown by allocator_traits<Allocator>::allocate[.](#10.sentence-1)
|
||||
|
||||
[ð](#lib:insert,basic_string_____)
|
||||
|
||||
`constexpr basic_string& insert(size_type pos, const charT* s);
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3724)
|
||||
|
||||
*Effects*: Equivalent to: return insert(pos, s, traits::length(s));
|
||||
|
||||
[ð](#lib:insert,basic_string______)
|
||||
|
||||
`constexpr basic_string& insert(size_type pos, size_type n, charT c);
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3735)
|
||||
|
||||
*Effects*: Inserts n copies of c before the character at position pos if pos < size(),
|
||||
or otherwise at the end of the string[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3741)
|
||||
|
||||
*Returns*: *this[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3745)
|
||||
|
||||
*Throws*:
|
||||
|
||||
- [(14.1)](#14.1)
|
||||
|
||||
out_of_range if pos > size(),
|
||||
|
||||
- [(14.2)](#14.2)
|
||||
|
||||
length_error if n > max_size() - size(), or
|
||||
|
||||
- [(14.3)](#14.3)
|
||||
|
||||
any exceptions thrown by allocator_traits<Allocator>::allocate[.](#14.sentence-1)
|
||||
|
||||
[ð](#lib:insert,basic_string_______)
|
||||
|
||||
`constexpr iterator insert(const_iterator p, charT c);
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3760)
|
||||
|
||||
*Preconditions*: p is a valid iterator on*this[.](#15.sentence-1)
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3765)
|
||||
|
||||
*Effects*: Inserts a copy of c at the position p[.](#16.sentence-1)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3769)
|
||||
|
||||
*Returns*: An iterator which refers to the inserted character[.](#17.sentence-1)
|
||||
|
||||
[ð](#lib:insert,basic_string________)
|
||||
|
||||
`constexpr iterator insert(const_iterator p, size_type n, charT c);
|
||||
`
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3780)
|
||||
|
||||
*Preconditions*: p is a valid iterator on*this[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3785)
|
||||
|
||||
*Effects*: Inserts n copies of c at the position p[.](#19.sentence-1)
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3789)
|
||||
|
||||
*Returns*: An iterator which refers to the first inserted character, orp if n == 0[.](#20.sentence-1)
|
||||
|
||||
[ð](#lib:insert,basic_string_________)
|
||||
|
||||
`template<class InputIterator>
|
||||
constexpr iterator insert(const_iterator p, InputIterator first, InputIterator last);
|
||||
`
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3802)
|
||||
|
||||
*Constraints*: InputIterator is a type that qualifies as an input
|
||||
iterator ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements"))[.](#21.sentence-1)
|
||||
|
||||
[22](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3807)
|
||||
|
||||
*Preconditions*: p is a valid iterator on*this[.](#22.sentence-1)
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3812)
|
||||
|
||||
*Effects*: Equivalent toinsert(p - begin(), basic_string(first, last, get_allocator()))[.](#23.sentence-1)
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3817)
|
||||
|
||||
*Returns*: An iterator which refers to the first inserted character, orp if first == last[.](#24.sentence-1)
|
||||
|
||||
[ð](#lib:insert_range,basic_string)
|
||||
|
||||
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<charT> R>
|
||||
constexpr iterator insert_range(const_iterator p, R&& rg);
|
||||
`
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3830)
|
||||
|
||||
*Preconditions*: p is a valid iterator on *this[.](#25.sentence-1)
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3834)
|
||||
|
||||
*Effects*: Equivalent toinsert(p - begin(), basic_string(from_range, std::forward<R>(rg), get_allocator()))[.](#26.sentence-1)
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3839)
|
||||
|
||||
*Returns*: An iterator which refers to the first inserted character, orp if rg is empty[.](#27.sentence-1)
|
||||
|
||||
[ð](#lib:insert,basic_string__________)
|
||||
|
||||
`constexpr iterator insert(const_iterator p, initializer_list<charT> il);
|
||||
`
|
||||
|
||||
[28](#28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3851)
|
||||
|
||||
*Effects*: Equivalent to: return insert(p, il.begin(), il.end());
|
||||
158
cppdraft/string/io.md
Normal file
158
cppdraft/string/io.md
Normal file
@@ -0,0 +1,158 @@
|
||||
[string.io]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.io)
|
||||
|
||||
### 27.4.4 Non-member functions [[string.nonmembers]](string.nonmembers#string.io)
|
||||
|
||||
#### 27.4.4.4 Inserters and extractors [string.io]
|
||||
|
||||
[ð](#lib:operator%3e%3e,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
basic_istream<charT, traits>&
|
||||
operator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5016)
|
||||
|
||||
*Effects*: Behaves as a formatted input function ([[istream.formatted.reqmts]](istream.formatted.reqmts "31.7.5.3.1 Common requirements"))[.](#1.sentence-1)
|
||||
|
||||
After constructing a sentry object,
|
||||
if the sentry object returns true when converted to a value of type bool,
|
||||
calls str.erase() and then extracts characters from is and appends them
|
||||
to str as if by callingstr.append(1, c)[.](#1.sentence-2)
|
||||
|
||||
Ifis.width() is greater than zero, the maximum
|
||||
number n of characters appended isis.width();
|
||||
otherwise n isstr.max_size()[.](#1.sentence-3)
|
||||
|
||||
Characters are extracted and appended until any of the following
|
||||
occurs:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
*n* characters are stored;
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
end-of-file occurs on the input sequence;
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
isspace(c, is.getloc()) is true for the next available input character*c*[.](#1.sentence-4)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5047)
|
||||
|
||||
After the last character (if any) is extracted,is.width(0) is called and thesentry object is destroyed[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5054)
|
||||
|
||||
If the function extracts no characters,ios_base::failbit is set in the input function's local error state
|
||||
before setstate is called[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5059)
|
||||
|
||||
*Returns*: is[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:operator%3c%3c,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os,
|
||||
const basic_string<charT, traits, Allocator>& str);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5073)
|
||||
|
||||
*Effects*: Equivalent to: return os << basic_string_view<charT, traits>(str);
|
||||
|
||||
[ð](#lib:getline,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
basic_istream<charT, traits>&
|
||||
getline(basic_istream<charT, traits>& is,
|
||||
basic_string<charT, traits, Allocator>& str,
|
||||
charT delim);
|
||||
template<class charT, class traits, class Allocator>
|
||||
basic_istream<charT, traits>&
|
||||
getline(basic_istream<charT, traits>&& is,
|
||||
basic_string<charT, traits, Allocator>& str,
|
||||
charT delim);
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5093)
|
||||
|
||||
*Effects*: Behaves as an unformatted input function ([[istream.unformatted]](istream.unformatted "31.7.5.4 Unformatted input functions")),
|
||||
except that it does not affect the value returned by subsequent calls tobasic_istream<>::gcount()[.](#6.sentence-1)
|
||||
|
||||
After constructing a sentry object,
|
||||
if the sentry object returns true when converted to a value of type bool,
|
||||
calls str.erase() and then extracts characters from is and appends them
|
||||
to str as if by callingstr.append(1, c) until any of the following occurs:
|
||||
|
||||
- [(6.1)](#6.1)
|
||||
|
||||
end-of-file occurs on the input sequence;
|
||||
|
||||
- [(6.2)](#6.2)
|
||||
|
||||
traits::eq(c, delim) for the next available input character*c* (in which case,*c* is extracted but not appended);
|
||||
|
||||
- [(6.3)](#6.3)
|
||||
|
||||
str.max_size() characters are stored
|
||||
(in which case,ios_base::failbit is set in the input function's local error state)[.](#6.sentence-2)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5123)
|
||||
|
||||
The conditions are tested in the order shown[.](#7.sentence-1)
|
||||
|
||||
In any case,
|
||||
after the last character is extracted, thesentry object is destroyed[.](#7.sentence-2)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5130)
|
||||
|
||||
If the function extracts no characters,ios_base::failbit is set in the input function's local error state
|
||||
before setstate is called[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5135)
|
||||
|
||||
*Returns*: is[.](#9.sentence-1)
|
||||
|
||||
[ð](#lib:getline,basic_string_)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
basic_istream<charT, traits>&
|
||||
getline(basic_istream<charT, traits>& is,
|
||||
basic_string<charT, traits, Allocator>& str);
|
||||
template<class charT, class traits, class Allocator>
|
||||
basic_istream<charT, traits>&
|
||||
getline(basic_istream<charT, traits>&& is,
|
||||
basic_string<charT, traits, Allocator>& str);
|
||||
`
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5153)
|
||||
|
||||
*Returns*: getline(is, str, is.widen('\n'))[.](#10.sentence-1)
|
||||
61
cppdraft/string/iterators.md
Normal file
61
cppdraft/string/iterators.md
Normal file
@@ -0,0 +1,61 @@
|
||||
[string.iterators]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.iterators)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.iterators)
|
||||
|
||||
#### 27.4.3.4 Iterator support [string.iterators]
|
||||
|
||||
[ð](#lib:begin,basic_string)
|
||||
|
||||
`constexpr iterator begin() noexcept;
|
||||
constexpr const_iterator begin() const noexcept;
|
||||
constexpr const_iterator cbegin() const noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2813)
|
||||
|
||||
*Returns*: An iterator referring to the first character in the string[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:end,basic_string)
|
||||
|
||||
`constexpr iterator end() noexcept;
|
||||
constexpr const_iterator end() const noexcept;
|
||||
constexpr const_iterator cend() const noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2827)
|
||||
|
||||
*Returns*: An iterator which is the past-the-end value[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:rbegin,basic_string)
|
||||
|
||||
`constexpr reverse_iterator rbegin() noexcept;
|
||||
constexpr const_reverse_iterator rbegin() const noexcept;
|
||||
constexpr const_reverse_iterator crbegin() const noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2841)
|
||||
|
||||
*Returns*: An iterator which is semantically equivalent toreverse_iterator(end())[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:rend,basic_string)
|
||||
|
||||
`constexpr reverse_iterator rend() noexcept;
|
||||
constexpr const_reverse_iterator rend() const noexcept;
|
||||
constexpr const_reverse_iterator crend() const noexcept;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L2856)
|
||||
|
||||
*Returns*: An iterator which is semantically equivalent toreverse_iterator(begin())[.](#4.sentence-1)
|
||||
1196
cppdraft/string/modifiers.md
Normal file
1196
cppdraft/string/modifiers.md
Normal file
File diff suppressed because it is too large
Load Diff
445
cppdraft/string/nonmembers.md
Normal file
445
cppdraft/string/nonmembers.md
Normal file
@@ -0,0 +1,445 @@
|
||||
[string.nonmembers]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.nonmembers)
|
||||
|
||||
### 27.4.4 Non-member functions [string.nonmembers]
|
||||
|
||||
#### [27.4.4.1](#string.op.plus) operator+ [[string.op.plus]](string.op.plus)
|
||||
|
||||
[ð](#lib:operator+,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
||||
const basic_string<charT, traits, Allocator>& rhs);
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);
|
||||
`
|
||||
|
||||
[1](#string.op.plus-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4719)
|
||||
|
||||
*Effects*: Equivalent to:basic_string<charT, traits, Allocator> r = lhs;
|
||||
r.append(rhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string_)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
||||
const basic_string<charT, traits, Allocator>& rhs);
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(basic_string<charT, traits, Allocator>&& lhs, const charT* rhs);
|
||||
`
|
||||
|
||||
[2](#string.op.plus-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4741)
|
||||
|
||||
*Effects*: Equivalent to:lhs.append(rhs);return std::move(lhs);
|
||||
|
||||
[ð](#lib:operator+,basic_string__)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs);
|
||||
`
|
||||
|
||||
[3](#string.op.plus-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4759)
|
||||
|
||||
*Effects*: Equivalent to:lhs.append(rhs);return std::move(lhs); except that both lhs and rhs are left in valid but unspecified states[.](#string.op.plus-3.sentence-1)
|
||||
|
||||
[*Note [1](#string.op.plus-note-1)*:
|
||||
|
||||
If lhs and rhs have equal allocators,
|
||||
the implementation can move from either[.](#string.op.plus-3.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[ð](#lib:operator+,basic_string___)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs);
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const charT* lhs, basic_string<charT, traits, Allocator>&& rhs);
|
||||
`
|
||||
|
||||
[4](#string.op.plus-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4786)
|
||||
|
||||
*Effects*: Equivalent to:rhs.insert(0, lhs);return std::move(rhs);
|
||||
|
||||
[ð](#lib:operator+,basic_string____)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs);
|
||||
`
|
||||
|
||||
[5](#string.op.plus-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4803)
|
||||
|
||||
*Effects*: Equivalent to:basic_string<charT, traits, Allocator> r = rhs;
|
||||
r.insert(0, lhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string_____)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(charT lhs, const basic_string<charT, traits, Allocator>& rhs);
|
||||
`
|
||||
|
||||
[6](#string.op.plus-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4821)
|
||||
|
||||
*Effects*: Equivalent to:basic_string<charT, traits, Allocator> r = rhs;
|
||||
r.insert(r.begin(), lhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string______)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(charT lhs, basic_string<charT, traits, Allocator>&& rhs);
|
||||
`
|
||||
|
||||
[7](#string.op.plus-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4839)
|
||||
|
||||
*Effects*: Equivalent to:rhs.insert(rhs.begin(), lhs);return std::move(rhs);
|
||||
|
||||
[ð](#lib:operator+,basic_string_______)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs);
|
||||
`
|
||||
|
||||
[8](#string.op.plus-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4856)
|
||||
|
||||
*Effects*: Equivalent to:basic_string<charT, traits, Allocator> r = lhs;
|
||||
r.push_back(rhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string________)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(basic_string<charT, traits, Allocator>&& lhs, charT rhs);
|
||||
`
|
||||
|
||||
[9](#string.op.plus-9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4874)
|
||||
|
||||
*Effects*: Equivalent to:lhs.push_back(rhs);return std::move(lhs);
|
||||
|
||||
[ð](#lib:operator+,basic_string_________)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
||||
type_identity_t<basic_string_view<charT, traits>> rhs);
|
||||
`
|
||||
|
||||
[10](#string.op.plus-10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4892)
|
||||
|
||||
Equivalent to:basic_string<charT, traits, Allocator> r = lhs;
|
||||
r.append(rhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string__________)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
||||
type_identity_t<basic_string_view<charT, traits>> rhs);
|
||||
`
|
||||
|
||||
[11](#string.op.plus-11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4910)
|
||||
|
||||
Equivalent to:lhs.append(rhs);return std::move(lhs);
|
||||
|
||||
[ð](#lib:operator+,basic_string___________)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
|
||||
const basic_string<charT, traits, Allocator>& rhs);
|
||||
`
|
||||
|
||||
[12](#string.op.plus-12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4927)
|
||||
|
||||
Equivalent to:basic_string<charT, traits, Allocator> r = rhs;
|
||||
r.insert(0, lhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string____________)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs);
|
||||
`
|
||||
|
||||
[13](#string.op.plus-13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4945)
|
||||
|
||||
Equivalent to:rhs.insert(0, lhs);return std::move(rhs);
|
||||
|
||||
[14](#string.op.plus-14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4953)
|
||||
|
||||
[*Note [2](#string.op.plus-note-2)*:
|
||||
|
||||
Using a specialization of type_identity_t as a parameter type ensures
|
||||
that an object of type basic_string<charT, traits, Allocator> can be concatenated with an object of a type T having an implicit conversion tobasic_string_view<charT, traits> ([[over.match.oper]](over.match.oper "12.2.2.3 Operators in expressions"))[.](#string.op.plus-14.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
|
||||
#### [27.4.4.2](#string.cmp) Non-member comparison operator functions [[string.cmp]](string.cmp)
|
||||
|
||||
[ð](#string.cmp-itemdecl:1)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr bool
|
||||
operator==(const basic_string<charT, traits, Allocator>& lhs,
|
||||
const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr bool operator==(const basic_string<charT, traits, Allocator>& lhs,
|
||||
const charT* rhs);
|
||||
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,
|
||||
const basic_string<charT, traits, Allocator>& rhs) noexcept;
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr see below operator<=>(const basic_string<charT, traits, Allocator>& lhs,
|
||||
const charT* rhs);
|
||||
`
|
||||
|
||||
[1](#string.cmp-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4980)
|
||||
|
||||
*Effects*: Let *op* be the operator[.](#string.cmp-1.sentence-1)
|
||||
|
||||
Equivalent to:return basic_string_view<charT, traits>(lhs) *op* basic_string_view<charT, traits>(rhs);
|
||||
|
||||
#### [27.4.4.3](#string.special) swap [[string.special]](string.special)
|
||||
|
||||
[ð](#lib:swap,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr void
|
||||
swap(basic_string<charT, traits, Allocator>& lhs,
|
||||
basic_string<charT, traits, Allocator>& rhs)
|
||||
noexcept(noexcept(lhs.swap(rhs)));
|
||||
`
|
||||
|
||||
[1](#string.special-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5001)
|
||||
|
||||
*Effects*: Equivalent to lhs.swap(rhs)[.](#string.special-1.sentence-1)
|
||||
|
||||
#### [27.4.4.4](#string.io) Inserters and extractors [[string.io]](string.io)
|
||||
|
||||
[ð](#lib:operator%3e%3e,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
basic_istream<charT, traits>&
|
||||
operator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
|
||||
`
|
||||
|
||||
[1](#string.io-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5016)
|
||||
|
||||
*Effects*: Behaves as a formatted input function ([[istream.formatted.reqmts]](istream.formatted.reqmts "31.7.5.3.1 Common requirements"))[.](#string.io-1.sentence-1)
|
||||
|
||||
After constructing a sentry object,
|
||||
if the sentry object returns true when converted to a value of type bool,
|
||||
calls str.erase() and then extracts characters from is and appends them
|
||||
to str as if by callingstr.append(1, c)[.](#string.io-1.sentence-2)
|
||||
|
||||
Ifis.width() is greater than zero, the maximum
|
||||
number n of characters appended isis.width();
|
||||
otherwise n isstr.max_size()[.](#string.io-1.sentence-3)
|
||||
|
||||
Characters are extracted and appended until any of the following
|
||||
occurs:
|
||||
|
||||
- [(1.1)](#string.io-1.1)
|
||||
|
||||
*n* characters are stored;
|
||||
|
||||
- [(1.2)](#string.io-1.2)
|
||||
|
||||
end-of-file occurs on the input sequence;
|
||||
|
||||
- [(1.3)](#string.io-1.3)
|
||||
|
||||
isspace(c, is.getloc()) is true for the next available input character*c*[.](#string.io-1.sentence-4)
|
||||
|
||||
[2](#string.io-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5047)
|
||||
|
||||
After the last character (if any) is extracted,is.width(0) is called and thesentry object is destroyed[.](#string.io-2.sentence-1)
|
||||
|
||||
[3](#string.io-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5054)
|
||||
|
||||
If the function extracts no characters,ios_base::failbit is set in the input function's local error state
|
||||
before setstate is called[.](#string.io-3.sentence-1)
|
||||
|
||||
[4](#string.io-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5059)
|
||||
|
||||
*Returns*: is[.](#string.io-4.sentence-1)
|
||||
|
||||
[ð](#lib:operator%3c%3c,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os,
|
||||
const basic_string<charT, traits, Allocator>& str);
|
||||
`
|
||||
|
||||
[5](#string.io-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5073)
|
||||
|
||||
*Effects*: Equivalent to: return os << basic_string_view<charT, traits>(str);
|
||||
|
||||
[ð](#lib:getline,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
basic_istream<charT, traits>&
|
||||
getline(basic_istream<charT, traits>& is,
|
||||
basic_string<charT, traits, Allocator>& str,
|
||||
charT delim);
|
||||
template<class charT, class traits, class Allocator>
|
||||
basic_istream<charT, traits>&
|
||||
getline(basic_istream<charT, traits>&& is,
|
||||
basic_string<charT, traits, Allocator>& str,
|
||||
charT delim);
|
||||
`
|
||||
|
||||
[6](#string.io-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5093)
|
||||
|
||||
*Effects*: Behaves as an unformatted input function ([[istream.unformatted]](istream.unformatted "31.7.5.4 Unformatted input functions")),
|
||||
except that it does not affect the value returned by subsequent calls tobasic_istream<>::gcount()[.](#string.io-6.sentence-1)
|
||||
|
||||
After constructing a sentry object,
|
||||
if the sentry object returns true when converted to a value of type bool,
|
||||
calls str.erase() and then extracts characters from is and appends them
|
||||
to str as if by callingstr.append(1, c) until any of the following occurs:
|
||||
|
||||
- [(6.1)](#string.io-6.1)
|
||||
|
||||
end-of-file occurs on the input sequence;
|
||||
|
||||
- [(6.2)](#string.io-6.2)
|
||||
|
||||
traits::eq(c, delim) for the next available input character*c* (in which case,*c* is extracted but not appended);
|
||||
|
||||
- [(6.3)](#string.io-6.3)
|
||||
|
||||
str.max_size() characters are stored
|
||||
(in which case,ios_base::failbit is set in the input function's local error state)[.](#string.io-6.sentence-2)
|
||||
|
||||
[7](#string.io-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5123)
|
||||
|
||||
The conditions are tested in the order shown[.](#string.io-7.sentence-1)
|
||||
|
||||
In any case,
|
||||
after the last character is extracted, thesentry object is destroyed[.](#string.io-7.sentence-2)
|
||||
|
||||
[8](#string.io-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5130)
|
||||
|
||||
If the function extracts no characters,ios_base::failbit is set in the input function's local error state
|
||||
before setstate is called[.](#string.io-8.sentence-1)
|
||||
|
||||
[9](#string.io-9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5135)
|
||||
|
||||
*Returns*: is[.](#string.io-9.sentence-1)
|
||||
|
||||
[ð](#lib:getline,basic_string_)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
basic_istream<charT, traits>&
|
||||
getline(basic_istream<charT, traits>& is,
|
||||
basic_string<charT, traits, Allocator>& str);
|
||||
template<class charT, class traits, class Allocator>
|
||||
basic_istream<charT, traits>&
|
||||
getline(basic_istream<charT, traits>&& is,
|
||||
basic_string<charT, traits, Allocator>& str);
|
||||
`
|
||||
|
||||
[10](#string.io-10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5153)
|
||||
|
||||
*Returns*: getline(is, str, is.widen('\n'))[.](#string.io-10.sentence-1)
|
||||
|
||||
#### [27.4.4.5](#string.erasure) Erasure [[string.erasure]](string.erasure)
|
||||
|
||||
[ð](#lib:erase,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator, class U = charT>
|
||||
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
||||
erase(basic_string<charT, traits, Allocator>& c, const U& value);
|
||||
`
|
||||
|
||||
[1](#string.erasure-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5168)
|
||||
|
||||
*Effects*: Equivalent to:auto it = remove(c.begin(), c.end(), value);auto r = distance(it, c.end());
|
||||
c.erase(it, c.end());return r;
|
||||
|
||||
[ð](#lib:erase_if,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator, class Predicate>
|
||||
constexpr typename basic_string<charT, traits, Allocator>::size_type
|
||||
erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred);
|
||||
`
|
||||
|
||||
[2](#string.erasure-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5187)
|
||||
|
||||
*Effects*: Equivalent to:auto it = remove_if(c.begin(), c.end(), pred);auto r = distance(it, c.end());
|
||||
c.erase(it, c.end());return r;
|
||||
81
cppdraft/string/op/append.md
Normal file
81
cppdraft/string/op/append.md
Normal file
@@ -0,0 +1,81 @@
|
||||
[string.op.append]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.op.append)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.op.append)
|
||||
|
||||
#### 27.4.3.7 Modifiers [[string.modifiers]](string.modifiers#string.op.append)
|
||||
|
||||
#### 27.4.3.7.1 basic_string::operator+= [string.op.append]
|
||||
|
||||
[ð](#lib:operator+=,basic_string)
|
||||
|
||||
`constexpr basic_string& operator+=(const basic_string& str);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3178)
|
||||
|
||||
*Effects*: Equivalent to: return append(str);
|
||||
|
||||
[ð](#lib:operator+=,basic_string_)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& operator+=(const T& t);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3192)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(2.1)](#2.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(2.2)](#2.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3203)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return append(sv);
|
||||
|
||||
[ð](#lib:operator+=,basic_string__)
|
||||
|
||||
`constexpr basic_string& operator+=(const charT* s);
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3218)
|
||||
|
||||
*Effects*: Equivalent to: return append(s);
|
||||
|
||||
[ð](#lib:operator+=,basic_string___)
|
||||
|
||||
`constexpr basic_string& operator+=(charT c);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3229)
|
||||
|
||||
*Effects*: Equivalent to: return append(size_type{1}, c);
|
||||
|
||||
[ð](#lib:operator+=,basic_string____)
|
||||
|
||||
`constexpr basic_string& operator+=(initializer_list<charT> il);
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3240)
|
||||
|
||||
*Effects*: Equivalent to: return append(il);
|
||||
219
cppdraft/string/op/plus.md
Normal file
219
cppdraft/string/op/plus.md
Normal file
@@ -0,0 +1,219 @@
|
||||
[string.op.plus]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.op.plus)
|
||||
|
||||
### 27.4.4 Non-member functions [[string.nonmembers]](string.nonmembers#string.op.plus)
|
||||
|
||||
#### 27.4.4.1 operator+ [string.op.plus]
|
||||
|
||||
[ð](#lib:operator+,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
||||
const basic_string<charT, traits, Allocator>& rhs);
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4719)
|
||||
|
||||
*Effects*: Equivalent to:basic_string<charT, traits, Allocator> r = lhs;
|
||||
r.append(rhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string_)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
||||
const basic_string<charT, traits, Allocator>& rhs);
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(basic_string<charT, traits, Allocator>&& lhs, const charT* rhs);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4741)
|
||||
|
||||
*Effects*: Equivalent to:lhs.append(rhs);return std::move(lhs);
|
||||
|
||||
[ð](#lib:operator+,basic_string__)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4759)
|
||||
|
||||
*Effects*: Equivalent to:lhs.append(rhs);return std::move(lhs); except that both lhs and rhs are left in valid but unspecified states[.](#3.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
If lhs and rhs have equal allocators,
|
||||
the implementation can move from either[.](#3.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[ð](#lib:operator+,basic_string___)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs);
|
||||
template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const charT* lhs, basic_string<charT, traits, Allocator>&& rhs);
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4786)
|
||||
|
||||
*Effects*: Equivalent to:rhs.insert(0, lhs);return std::move(rhs);
|
||||
|
||||
[ð](#lib:operator+,basic_string____)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4803)
|
||||
|
||||
*Effects*: Equivalent to:basic_string<charT, traits, Allocator> r = rhs;
|
||||
r.insert(0, lhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string_____)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(charT lhs, const basic_string<charT, traits, Allocator>& rhs);
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4821)
|
||||
|
||||
*Effects*: Equivalent to:basic_string<charT, traits, Allocator> r = rhs;
|
||||
r.insert(r.begin(), lhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string______)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(charT lhs, basic_string<charT, traits, Allocator>&& rhs);
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4839)
|
||||
|
||||
*Effects*: Equivalent to:rhs.insert(rhs.begin(), lhs);return std::move(rhs);
|
||||
|
||||
[ð](#lib:operator+,basic_string_______)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs);
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4856)
|
||||
|
||||
*Effects*: Equivalent to:basic_string<charT, traits, Allocator> r = lhs;
|
||||
r.push_back(rhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string________)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(basic_string<charT, traits, Allocator>&& lhs, charT rhs);
|
||||
`
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4874)
|
||||
|
||||
*Effects*: Equivalent to:lhs.push_back(rhs);return std::move(lhs);
|
||||
|
||||
[ð](#lib:operator+,basic_string_________)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(const basic_string<charT, traits, Allocator>& lhs,
|
||||
type_identity_t<basic_string_view<charT, traits>> rhs);
|
||||
`
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4892)
|
||||
|
||||
Equivalent to:basic_string<charT, traits, Allocator> r = lhs;
|
||||
r.append(rhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string__________)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(basic_string<charT, traits, Allocator>&& lhs,
|
||||
type_identity_t<basic_string_view<charT, traits>> rhs);
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4910)
|
||||
|
||||
Equivalent to:lhs.append(rhs);return std::move(lhs);
|
||||
|
||||
[ð](#lib:operator+,basic_string___________)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
|
||||
const basic_string<charT, traits, Allocator>& rhs);
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4927)
|
||||
|
||||
Equivalent to:basic_string<charT, traits, Allocator> r = rhs;
|
||||
r.insert(0, lhs);return r;
|
||||
|
||||
[ð](#lib:operator+,basic_string____________)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr basic_string<charT, traits, Allocator>
|
||||
operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs);
|
||||
`
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4945)
|
||||
|
||||
Equivalent to:rhs.insert(0, lhs);return std::move(rhs);
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4953)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
Using a specialization of type_identity_t as a parameter type ensures
|
||||
that an object of type basic_string<charT, traits, Allocator> can be concatenated with an object of a type T having an implicit conversion tobasic_string_view<charT, traits> ([[over.match.oper]](over.match.oper "12.2.2.3 Operators in expressions"))[.](#14.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
383
cppdraft/string/ops.md
Normal file
383
cppdraft/string/ops.md
Normal file
@@ -0,0 +1,383 @@
|
||||
[string.ops]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.ops)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.ops)
|
||||
|
||||
#### 27.4.3.8 String operations [string.ops]
|
||||
|
||||
#### [27.4.3.8.1](#string.accessors) Accessors [[string.accessors]](string.accessors)
|
||||
|
||||
[ð](#lib:c_str,basic_string)
|
||||
|
||||
`constexpr const charT* c_str() const noexcept;
|
||||
constexpr const charT* data() const noexcept;
|
||||
`
|
||||
|
||||
[1](#string.accessors-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4297)
|
||||
|
||||
*Returns*: A pointer p such that p + i == addressof(operator[](i)) for eachi in [0, size()][.](#string.accessors-1.sentence-1)
|
||||
|
||||
[2](#string.accessors-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4302)
|
||||
|
||||
*Complexity*: Constant time[.](#string.accessors-2.sentence-1)
|
||||
|
||||
[3](#string.accessors-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4306)
|
||||
|
||||
*Remarks*: The program shall not modify any of the values stored in the character array; otherwise, the behavior is undefined[.](#string.accessors-3.sentence-1)
|
||||
|
||||
[ð](#lib:data,basic_string_)
|
||||
|
||||
`constexpr charT* data() noexcept;
|
||||
`
|
||||
|
||||
[4](#string.accessors-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4317)
|
||||
|
||||
*Returns*: A pointer p such that p + i == addressof(operator[](i)) for eachi in [0, size()][.](#string.accessors-4.sentence-1)
|
||||
|
||||
[5](#string.accessors-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4322)
|
||||
|
||||
*Complexity*: Constant time[.](#string.accessors-5.sentence-1)
|
||||
|
||||
[6](#string.accessors-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4326)
|
||||
|
||||
*Remarks*: The program shall not modify the value stored at p + size() to any value other than charT(); otherwise, the behavior is undefined[.](#string.accessors-6.sentence-1)
|
||||
|
||||
[ð](#lib:operator_basic_string_view,basic_string)
|
||||
|
||||
`constexpr operator basic_string_view<charT, traits>() const noexcept;
|
||||
`
|
||||
|
||||
[7](#string.accessors-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4338)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(data(), size());
|
||||
|
||||
[ð](#lib:get_allocator,basic_string)
|
||||
|
||||
`constexpr allocator_type get_allocator() const noexcept;
|
||||
`
|
||||
|
||||
[8](#string.accessors-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4350)
|
||||
|
||||
*Returns*: A copy of theAllocator object used to construct the string or, if that allocator has been replaced, a
|
||||
copy of the most recent replacement[.](#string.accessors-8.sentence-1)
|
||||
|
||||
#### [27.4.3.8.2](#string.find) Searching [[string.find]](string.find)
|
||||
|
||||
[1](#string.find-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4360)
|
||||
|
||||
Let *F* be one offind, rfind, find_first_of, find_last_of,find_first_not_of, and find_last_not_of[.](#string.find-1.sentence-1)
|
||||
|
||||
- [(1.1)](#string.find-1.1)
|
||||
|
||||
Each member function of the formconstexpr size_type *F*(const basic_string& str, size_type pos) const noexcept; has effects equivalent to:return *F*(basic_string_view<charT, traits>(str), pos);
|
||||
|
||||
- [(1.2)](#string.find-1.2)
|
||||
|
||||
Each member function of the formconstexpr size_type *F*(const charT* s, size_type pos) const; has effects equivalent to:return *F*(basic_string_view<charT, traits>(s), pos);
|
||||
|
||||
- [(1.3)](#string.find-1.3)
|
||||
|
||||
Each member function of the formconstexpr size_type *F*(const charT* s, size_type pos, size_type n) const; has effects equivalent to:return *F*(basic_string_view<charT, traits>(s, n), pos);
|
||||
|
||||
- [(1.4)](#string.find-1.4)
|
||||
|
||||
Each member function of the formconstexpr size_type *F*(charT c, size_type pos) const noexcept; has effects equivalent to:return *F*(basic_string_view<charT, traits>(addressof(c), 1), pos);
|
||||
|
||||
[ð](#lib:find,basic_string_)
|
||||
|
||||
`template<class T>
|
||||
constexpr size_type find(const T& t, size_type pos = 0) const noexcept(see below);
|
||||
template<class T>
|
||||
constexpr size_type rfind(const T& t, size_type pos = npos) const noexcept(see below);
|
||||
template<class T>
|
||||
constexpr size_type find_first_of(const T& t, size_type pos = 0) const noexcept(see below);
|
||||
template<class T>
|
||||
constexpr size_type find_last_of(const T& t, size_type pos = npos) const noexcept(see below);
|
||||
template<class T>
|
||||
constexpr size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept(see below);
|
||||
template<class T>
|
||||
constexpr size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept(see below);
|
||||
`
|
||||
|
||||
[2](#string.find-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4429)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(2.1)](#string.find-2.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(2.2)](#string.find-2.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#string.find-2.sentence-1)
|
||||
|
||||
[3](#string.find-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4440)
|
||||
|
||||
*Effects*: Let *G* be the name of the function[.](#string.find-3.sentence-1)
|
||||
|
||||
Equivalent to:basic_string_view<charT, traits> s = *this, sv = t;return s.*G*(sv, pos);
|
||||
|
||||
[4](#string.find-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4449)
|
||||
|
||||
*Remarks*: The exception specification is equivalent tois_nothrow_convertible_v<const T&, basic_string_view<charT, traits>>[.](#string.find-4.sentence-1)
|
||||
|
||||
#### [27.4.3.8.3](#string.substr) basic_string::substr [[string.substr]](string.substr)
|
||||
|
||||
[ð](#lib:substr,basic_string)
|
||||
|
||||
`constexpr basic_string substr(size_type pos = 0, size_type n = npos) const &;
|
||||
`
|
||||
|
||||
[1](#string.substr-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4463)
|
||||
|
||||
*Effects*: Equivalent to: return basic_string(*this, pos, n);
|
||||
|
||||
[ð](#lib:substr,basic_string_)
|
||||
|
||||
`constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&;
|
||||
`
|
||||
|
||||
[2](#string.substr-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4474)
|
||||
|
||||
*Effects*: Equivalent to: return basic_string(std::move(*this), pos, n);
|
||||
|
||||
[ð](#lib:subview,basic_string)
|
||||
|
||||
`constexpr basic_string_view<charT, traits> subview(size_type pos = 0, size_type n = npos) const;
|
||||
`
|
||||
|
||||
[3](#string.substr-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4485)
|
||||
|
||||
*Effects*: Equivalent to: return basic_string_view<charT, traits>(*this).subview(pos, n);
|
||||
|
||||
#### [27.4.3.8.4](#string.compare) basic_string::compare [[string.compare]](string.compare)
|
||||
|
||||
[ð](#lib:compare,basic_string)
|
||||
|
||||
`template<class T>
|
||||
constexpr int compare(const T& t) const noexcept(see below);
|
||||
`
|
||||
|
||||
[1](#string.compare-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4499)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(1.1)](#string.compare-1.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(1.2)](#string.compare-1.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#string.compare-1.sentence-1)
|
||||
|
||||
[2](#string.compare-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4510)
|
||||
|
||||
*Effects*: Equivalent to: return basic_string_view<charT, traits>(*this).compare(t);
|
||||
|
||||
[3](#string.compare-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4514)
|
||||
|
||||
*Remarks*: The exception specification is equivalent tois_nothrow_convertible_v<const T&, basic_string_view<charT, traits>>[.](#string.compare-3.sentence-1)
|
||||
|
||||
[ð](#lib:compare,basic_string_)
|
||||
|
||||
`template<class T>
|
||||
constexpr int compare(size_type pos1, size_type n1, const T& t) const;
|
||||
`
|
||||
|
||||
[4](#string.compare-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4527)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(4.1)](#string.compare-4.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(4.2)](#string.compare-4.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#string.compare-4.sentence-1)
|
||||
|
||||
[5](#string.compare-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4538)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(*this).substr(pos1, n1).compare(t);
|
||||
|
||||
[ð](#lib:compare,basic_string__)
|
||||
|
||||
`template<class T>
|
||||
constexpr int compare(size_type pos1, size_type n1, const T& t,
|
||||
size_type pos2, size_type n2 = npos) const;
|
||||
`
|
||||
|
||||
[6](#string.compare-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4554)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(6.1)](#string.compare-6.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(6.2)](#string.compare-6.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#string.compare-6.sentence-1)
|
||||
|
||||
[7](#string.compare-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4565)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> s = *this, sv = t;return s.substr(pos1, n1).compare(sv.substr(pos2, n2));
|
||||
|
||||
[ð](#lib:compare,basic_string___)
|
||||
|
||||
`constexpr int compare(const basic_string& str) const noexcept;
|
||||
`
|
||||
|
||||
[8](#string.compare-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4580)
|
||||
|
||||
*Effects*: Equivalent to:return compare(basic_string_view<charT, traits>(str));
|
||||
|
||||
[ð](#lib:compare,basic_string____)
|
||||
|
||||
`constexpr int compare(size_type pos1, size_type n1, const basic_string& str) const;
|
||||
`
|
||||
|
||||
[9](#string.compare-9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4592)
|
||||
|
||||
*Effects*: Equivalent to:return compare(pos1, n1, basic_string_view<charT, traits>(str));
|
||||
|
||||
[ð](#lib:compare,basic_string_____)
|
||||
|
||||
`constexpr int compare(size_type pos1, size_type n1, const basic_string& str,
|
||||
size_type pos2, size_type n2 = npos) const;
|
||||
`
|
||||
|
||||
[10](#string.compare-10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4605)
|
||||
|
||||
*Effects*: Equivalent to:return compare(pos1, n1, basic_string_view<charT, traits>(str), pos2, n2);
|
||||
|
||||
[ð](#lib:compare,basic_string______)
|
||||
|
||||
`constexpr int compare(const charT* s) const;
|
||||
`
|
||||
|
||||
[11](#string.compare-11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4619)
|
||||
|
||||
*Effects*: Equivalent to:return compare(basic_string_view<charT, traits>(s));
|
||||
|
||||
[ð](#lib:compare,basic_string_______)
|
||||
|
||||
`constexpr int compare(size_type pos, size_type n1, const charT* s) const;
|
||||
`
|
||||
|
||||
[12](#string.compare-12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4631)
|
||||
|
||||
*Effects*: Equivalent to: return compare(pos, n1, basic_string_view<charT, traits>(s));
|
||||
|
||||
[ð](#lib:compare,basic_string________)
|
||||
|
||||
`constexpr int compare(size_type pos, size_type n1, const charT* s, size_type n2) const;
|
||||
`
|
||||
|
||||
[13](#string.compare-13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4642)
|
||||
|
||||
*Effects*: Equivalent to: return compare(pos, n1, basic_string_view<charT, traits>(s, n2));
|
||||
|
||||
#### [27.4.3.8.5](#string.starts.with) basic_string::starts_with [[string.starts.with]](string.starts.with)
|
||||
|
||||
[ð](#lib:starts_with,basic_string)
|
||||
|
||||
`constexpr bool starts_with(basic_string_view<charT, traits> x) const noexcept;
|
||||
constexpr bool starts_with(charT x) const noexcept;
|
||||
constexpr bool starts_with(const charT* x) const;
|
||||
`
|
||||
|
||||
[1](#string.starts.with-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4657)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(data(), size()).starts_with(x);
|
||||
|
||||
#### [27.4.3.8.6](#string.ends.with) basic_string::ends_with [[string.ends.with]](string.ends.with)
|
||||
|
||||
[ð](#lib:ends_with,basic_string)
|
||||
|
||||
`constexpr bool ends_with(basic_string_view<charT, traits> x) const noexcept;
|
||||
constexpr bool ends_with(charT x) const noexcept;
|
||||
constexpr bool ends_with(const charT* x) const;
|
||||
`
|
||||
|
||||
[1](#string.ends.with-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4675)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(data(), size()).ends_with(x);
|
||||
|
||||
#### [27.4.3.8.7](#string.contains) basic_string::contains [[string.contains]](string.contains)
|
||||
|
||||
[ð](#lib:contains,basic_string)
|
||||
|
||||
`constexpr bool contains(basic_string_view<charT, traits> x) const noexcept;
|
||||
constexpr bool contains(charT x) const noexcept;
|
||||
constexpr bool contains(const charT* x) const;
|
||||
`
|
||||
|
||||
[1](#string.contains-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4693)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(data(), size()).contains(x);
|
||||
317
cppdraft/string/replace.md
Normal file
317
cppdraft/string/replace.md
Normal file
@@ -0,0 +1,317 @@
|
||||
[string.replace]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.replace)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.replace)
|
||||
|
||||
#### 27.4.3.7 Modifiers [[string.modifiers]](string.modifiers#string.replace)
|
||||
|
||||
#### 27.4.3.7.6 basic_string::replace [string.replace]
|
||||
|
||||
[ð](#lib:replace,basic_string)
|
||||
|
||||
`constexpr basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3965)
|
||||
|
||||
*Effects*: Equivalent to: return replace(pos1, n1, str.data(), str.size());
|
||||
|
||||
[ð](#lib:replace,basic_string_)
|
||||
|
||||
`constexpr basic_string& replace(size_type pos1, size_type n1, const basic_string& str,
|
||||
size_type pos2, size_type n2 = npos);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3977)
|
||||
|
||||
*Effects*: Equivalent to:return replace(pos1, n1, basic_string_view<charT, traits>(str).substr(pos2, n2));
|
||||
|
||||
[ð](#lib:replace,basic_string__)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& replace(size_type pos1, size_type n1, const T& t);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L3992)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4003)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return replace(pos1, n1, sv.data(), sv.size());
|
||||
|
||||
[ð](#lib:replace,basic_string___)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& replace(size_type pos1, size_type n1, const T& t,
|
||||
size_type pos2, size_type n2 = npos);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4020)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(5.1)](#5.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(5.2)](#5.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4031)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return replace(pos1, n1, sv.substr(pos2, n2));
|
||||
|
||||
[ð](#lib:replace,basic_string____)
|
||||
|
||||
`constexpr basic_string& replace(size_type pos1, size_type n1, const charT* s, size_type n2);
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4046)
|
||||
|
||||
*Preconditions*: [s, s + n2) is a valid range[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4050)
|
||||
|
||||
*Effects*: Determines the effective length xlen of the string to be
|
||||
removed as the smaller of n1 and size() - pos1[.](#8.sentence-1)
|
||||
|
||||
Ifsize() - xlen >= max_size() - n2 throws length_error[.](#8.sentence-2)
|
||||
|
||||
Otherwise,
|
||||
the function replaces the characters in the range
|
||||
[begin() + pos1, begin() + pos1 + xlen)
|
||||
with a copy of the range [s, s + n2)[.](#8.sentence-3)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4059)
|
||||
|
||||
*Returns*: *this[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4063)
|
||||
|
||||
*Throws*:
|
||||
|
||||
- [(10.1)](#10.1)
|
||||
|
||||
out_of_range if pos1 > size(),
|
||||
|
||||
- [(10.2)](#10.2)
|
||||
|
||||
length_error if the length of the resulting string
|
||||
would exceed max_size(), or
|
||||
|
||||
- [(10.3)](#10.3)
|
||||
|
||||
any exceptions thrown by allocator_traits<Allocator>::allocate[.](#10.sentence-1)
|
||||
|
||||
[ð](#lib:replace,basic_string_____)
|
||||
|
||||
`constexpr basic_string& replace(size_type pos, size_type n, const charT* s);
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4079)
|
||||
|
||||
*Effects*: Equivalent to: return replace(pos, n, s, traits::length(s));
|
||||
|
||||
[ð](#lib:replace,basic_string______)
|
||||
|
||||
`constexpr basic_string& replace(size_type pos1, size_type n1, size_type n2, charT c);
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4090)
|
||||
|
||||
*Effects*: Determines the effective length xlen of the string to be
|
||||
removed as the smaller of n1 and size() - pos1[.](#12.sentence-1)
|
||||
|
||||
Ifsize() - xlen >= max_size() - n2 throws length_error[.](#12.sentence-2)
|
||||
|
||||
Otherwise,
|
||||
the function replaces the characters in the range
|
||||
[begin() + pos1, begin() + pos1 + xlen)
|
||||
with n2 copies of c[.](#12.sentence-3)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4099)
|
||||
|
||||
*Returns*: *this[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4103)
|
||||
|
||||
*Throws*:
|
||||
|
||||
- [(14.1)](#14.1)
|
||||
|
||||
out_of_range if pos1 > size(),
|
||||
|
||||
- [(14.2)](#14.2)
|
||||
|
||||
length_error if the length of the resulting string
|
||||
would exceed max_size(), or
|
||||
|
||||
- [(14.3)](#14.3)
|
||||
|
||||
any exceptions thrown by allocator_traits<Allocator>::allocate.
|
||||
|
||||
[ð](#lib:replace,basic_string_______)
|
||||
|
||||
`constexpr basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4119)
|
||||
|
||||
*Effects*: Equivalent to: return replace(i1, i2, basic_string_view<charT, traits>(str));
|
||||
|
||||
[ð](#lib:replace,basic_string________)
|
||||
|
||||
`template<class T>
|
||||
constexpr basic_string& replace(const_iterator i1, const_iterator i2, const T& t);
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4131)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(16.1)](#16.1)
|
||||
|
||||
is_convertible_v<const T&, basic_string_view<charT, traits>> istrue and
|
||||
|
||||
- [(16.2)](#16.2)
|
||||
|
||||
is_convertible_v<const T&, const charT*> isfalse[.](#16.sentence-1)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4142)
|
||||
|
||||
*Preconditions*: [begin(), i1) and [i1, i2) are valid ranges[.](#17.sentence-1)
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4146)
|
||||
|
||||
*Effects*: Equivalent to:basic_string_view<charT, traits> sv = t;return replace(i1 - begin(), i2 - i1, sv.data(), sv.size());
|
||||
|
||||
[ð](#lib:replace,basic_string_________)
|
||||
|
||||
`constexpr basic_string& replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
|
||||
`
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4161)
|
||||
|
||||
*Effects*: Equivalent to: return replace(i1, i2, basic_string_view<charT, traits>(s, n));
|
||||
|
||||
[ð](#lib:replace,basic_string__________)
|
||||
|
||||
`constexpr basic_string& replace(const_iterator i1, const_iterator i2, const charT* s);
|
||||
`
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4172)
|
||||
|
||||
*Effects*: Equivalent to: return replace(i1, i2, basic_string_view<charT, traits>(s));
|
||||
|
||||
[ð](#lib:replace,basic_string___________)
|
||||
|
||||
`constexpr basic_string& replace(const_iterator i1, const_iterator i2, size_type n, charT c);
|
||||
`
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4183)
|
||||
|
||||
*Preconditions*: [begin(), i1) and [i1, i2) are valid ranges[.](#21.sentence-1)
|
||||
|
||||
[22](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4187)
|
||||
|
||||
*Effects*: Equivalent to: return replace(i1 - begin(), i2 - i1, n, c);
|
||||
|
||||
[ð](#lib:replace,basic_string____________)
|
||||
|
||||
`template<class InputIterator>
|
||||
constexpr basic_string& replace(const_iterator i1, const_iterator i2,
|
||||
InputIterator j1, InputIterator j2);
|
||||
`
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4200)
|
||||
|
||||
*Constraints*: InputIterator is a type that qualifies as an input
|
||||
iterator ([[container.reqmts]](container.reqmts "23.2.2.2 Container requirements"))[.](#23.sentence-1)
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4205)
|
||||
|
||||
*Effects*: Equivalent to: return replace(i1, i2, basic_string(j1, j2, get_allocator()));
|
||||
|
||||
[ð](#lib:replace_with_range,basic_string)
|
||||
|
||||
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]")<charT> R>
|
||||
constexpr basic_string& replace_with_range(const_iterator i1, const_iterator i2, R&& rg);
|
||||
`
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4217)
|
||||
|
||||
*Effects*: Equivalent to:return replace(i1, i2, basic_string(from_range, std::forward<R>(rg), get_allocator()));
|
||||
|
||||
[ð](#lib:replace,basic_string_____________)
|
||||
|
||||
`constexpr basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<charT> il);
|
||||
`
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4231)
|
||||
|
||||
*Effects*: Equivalent to: return replace(i1, i2, il.begin(), il.size());
|
||||
75
cppdraft/string/require.md
Normal file
75
cppdraft/string/require.md
Normal file
@@ -0,0 +1,75 @@
|
||||
[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)
|
||||
24
cppdraft/string/special.md
Normal file
24
cppdraft/string/special.md
Normal file
@@ -0,0 +1,24 @@
|
||||
[string.special]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.special)
|
||||
|
||||
### 27.4.4 Non-member functions [[string.nonmembers]](string.nonmembers#string.special)
|
||||
|
||||
#### 27.4.4.3 swap [string.special]
|
||||
|
||||
[ð](#lib:swap,basic_string)
|
||||
|
||||
`template<class charT, class traits, class Allocator>
|
||||
constexpr void
|
||||
swap(basic_string<charT, traits, Allocator>& lhs,
|
||||
basic_string<charT, traits, Allocator>& rhs)
|
||||
noexcept(noexcept(lhs.swap(rhs)));
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L5001)
|
||||
|
||||
*Effects*: Equivalent to lhs.swap(rhs)[.](#1.sentence-1)
|
||||
24
cppdraft/string/starts/with.md
Normal file
24
cppdraft/string/starts/with.md
Normal file
@@ -0,0 +1,24 @@
|
||||
[string.starts.with]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.starts.with)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.starts.with)
|
||||
|
||||
#### 27.4.3.8 String operations [[string.ops]](string.ops#string.starts.with)
|
||||
|
||||
#### 27.4.3.8.5 basic_string::starts_with [string.starts.with]
|
||||
|
||||
[ð](#lib:starts_with,basic_string)
|
||||
|
||||
`constexpr bool starts_with(basic_string_view<charT, traits> x) const noexcept;
|
||||
constexpr bool starts_with(charT x) const noexcept;
|
||||
constexpr bool starts_with(const charT* x) const;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4657)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view<charT, traits>(data(), size()).starts_with(x);
|
||||
1747
cppdraft/string/streams.md
Normal file
1747
cppdraft/string/streams.md
Normal file
File diff suppressed because it is too large
Load Diff
44
cppdraft/string/substr.md
Normal file
44
cppdraft/string/substr.md
Normal file
@@ -0,0 +1,44 @@
|
||||
[string.substr]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.substr)
|
||||
|
||||
### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.substr)
|
||||
|
||||
#### 27.4.3.8 String operations [[string.ops]](string.ops#string.substr)
|
||||
|
||||
#### 27.4.3.8.3 basic_string::substr [string.substr]
|
||||
|
||||
[ð](#lib:substr,basic_string)
|
||||
|
||||
`constexpr basic_string substr(size_type pos = 0, size_type n = npos) const &;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4463)
|
||||
|
||||
*Effects*: Equivalent to: return basic_string(*this, pos, n);
|
||||
|
||||
[ð](#lib:substr,basic_string_)
|
||||
|
||||
`constexpr basic_string substr(size_type pos = 0, size_type n = npos) &&;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4474)
|
||||
|
||||
*Effects*: Equivalent to: return basic_string(std::move(*this), pos, n);
|
||||
|
||||
[ð](#lib:subview,basic_string)
|
||||
|
||||
`constexpr basic_string_view<charT, traits> subview(size_type pos = 0, size_type n = npos) const;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4485)
|
||||
|
||||
*Effects*: Equivalent to: return basic_string_view<charT, traits>(*this).subview(pos, n);
|
||||
42
cppdraft/string/swap.md
Normal file
42
cppdraft/string/swap.md
Normal file
@@ -0,0 +1,42 @@
|
||||
[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)
|
||||
46
cppdraft/string/syn.md
Normal file
46
cppdraft/string/syn.md
Normal file
@@ -0,0 +1,46 @@
|
||||
[string.syn]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.4 String classes [[string.classes]](string.classes#string.syn)
|
||||
|
||||
### 27.4.2 Header <string> synopsis [string.syn]
|
||||
|
||||
#include <compare> // see [[compare.syn]](compare.syn "17.12.1 Header <compare> synopsis")#include <initializer_list> // see [[initializer.list.syn]](initializer.list.syn "17.11.2 Header <initializer_list> synopsis")namespace std {// [[char.traits]](char.traits "27.2 Character traits"), character traitstemplate<class charT> struct char_traits; // freestandingtemplate<> struct char_traits<char>; // freestandingtemplate<> struct char_traits<char8_t>; // freestandingtemplate<> struct char_traits<char16_t>; // freestandingtemplate<> struct char_traits<char32_t>; // freestandingtemplate<> struct char_traits<wchar_t>; // freestanding// [[basic.string]](basic.string "27.4.3 Class template basic_string"), basic_stringtemplate<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>class basic_string; template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(basic_string<charT, traits, Allocator>&& lhs, const basic_string<charT, traits, Allocator>& rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(const basic_string<charT, traits, Allocator>& lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(basic_string<charT, traits, Allocator>&& lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(const charT* lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(charT lhs, const basic_string<charT, traits, Allocator>& rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(charT lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(basic_string<charT, traits, Allocator>&& lhs, const charT* rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(const basic_string<charT, traits, Allocator>& lhs,
|
||||
charT rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(basic_string<charT, traits, Allocator>&& lhs,
|
||||
charT rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(const basic_string<charT, traits, Allocator>& lhs,
|
||||
type_identity_t<basic_string_view<charT, traits>> rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(basic_string<charT, traits, Allocator>&& lhs,
|
||||
type_identity_t<basic_string_view<charT, traits>> rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(type_identity_t<basic_string_view<charT, traits>> lhs, const basic_string<charT, traits, Allocator>& rhs); template<class charT, class traits, class Allocator>constexpr basic_string<charT, traits, Allocator>operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
|
||||
basic_string<charT, traits, Allocator>&& rhs); template<class charT, class traits, class Allocator>constexpr booloperator==(const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; template<class charT, class traits, class Allocator>constexpr bool operator==(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); template<class charT, class traits, class Allocator>constexpr *see below* operator<=>(const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; template<class charT, class traits, class Allocator>constexpr *see below* operator<=>(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); // [[string.special]](string.special "27.4.4.3 swap"), swaptemplate<class charT, class traits, class Allocator>constexpr void swap(basic_string<charT, traits, Allocator>& lhs,
|
||||
basic_string<charT, traits, Allocator>& rhs)noexcept(noexcept(lhs.swap(rhs))); // [[string.io]](string.io "27.4.4.4 Inserters and extractors"), inserters and extractorstemplate<class charT, class traits, class Allocator> basic_istream<charT, traits>&operator>>(basic_istream<charT, traits>& is,
|
||||
basic_string<charT, traits, Allocator>& str); template<class charT, class traits, class Allocator> basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str); template<class charT, class traits, class Allocator> basic_istream<charT, traits>& getline(basic_istream<charT, traits>& is,
|
||||
basic_string<charT, traits, Allocator>& str,
|
||||
charT delim); template<class charT, class traits, class Allocator> basic_istream<charT, traits>& getline(basic_istream<charT, traits>&& is,
|
||||
basic_string<charT, traits, Allocator>& str,
|
||||
charT delim); template<class charT, class traits, class Allocator> basic_istream<charT, traits>& getline(basic_istream<charT, traits>& is,
|
||||
basic_string<charT, traits, Allocator>& str); template<class charT, class traits, class Allocator> basic_istream<charT, traits>& getline(basic_istream<charT, traits>&& is,
|
||||
basic_string<charT, traits, Allocator>& str); // [[string.erasure]](string.erasure "27.4.4.5 Erasure"), erasuretemplate<class charT, class traits, class Allocator, class U = charT>constexpr typename basic_string<charT, traits, Allocator>::size_type
|
||||
erase(basic_string<charT, traits, Allocator>& c, const U& value); template<class charT, class traits, class Allocator, class Predicate>constexpr typename basic_string<charT, traits, Allocator>::size_type
|
||||
erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // basic_string [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]")*s*using [string](#lib:string "27.4.2 Header <string> synopsis [string.syn]") = basic_string<char>; using [u8string](#lib:u8string "27.4.2 Header <string> synopsis [string.syn]") = basic_string<char8_t>; using [u16string](#lib:u16string "27.4.2 Header <string> synopsis [string.syn]") = basic_string<char16_t>; using [u32string](#lib:u32string "27.4.2 Header <string> synopsis [string.syn]") = basic_string<char32_t>; using [wstring](#lib:wstring "27.4.2 Header <string> synopsis [string.syn]") = basic_string<wchar_t>; // [[string.conversions]](string.conversions "27.4.5 Numeric conversions"), numeric conversionsint stoi(const string& str, size_t* idx = nullptr, int base = 10); long stol(const string& str, size_t* idx = nullptr, int base = 10); unsigned long stoul(const string& str, size_t* idx = nullptr, int base = 10); long long stoll(const string& str, size_t* idx = nullptr, int base = 10); unsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10); float stof(const string& str, size_t* idx = nullptr); double stod(const string& str, size_t* idx = nullptr); long double stold(const string& str, size_t* idx = nullptr);
|
||||
string to_string(int val);
|
||||
string to_string(unsigned val);
|
||||
string to_string(long val);
|
||||
string to_string(unsigned long val);
|
||||
string to_string(long long val);
|
||||
string to_string(unsigned long long val);
|
||||
string to_string(float val);
|
||||
string to_string(double val);
|
||||
string to_string(long double val); int stoi(const wstring& str, size_t* idx = nullptr, int base = 10); long stol(const wstring& str, size_t* idx = nullptr, int base = 10); unsigned long stoul(const wstring& str, size_t* idx = nullptr, int base = 10); long long stoll(const wstring& str, size_t* idx = nullptr, int base = 10); unsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10); float stof(const wstring& str, size_t* idx = nullptr); double stod(const wstring& str, size_t* idx = nullptr); long double stold(const wstring& str, size_t* idx = nullptr);
|
||||
wstring to_wstring(int val);
|
||||
wstring to_wstring(unsigned val);
|
||||
wstring to_wstring(long val);
|
||||
wstring to_wstring(unsigned long val);
|
||||
wstring to_wstring(long long val);
|
||||
wstring to_wstring(unsigned long long val);
|
||||
wstring to_wstring(float val);
|
||||
wstring to_wstring(double val);
|
||||
wstring to_wstring(long double val); namespace pmr {template<class charT, class traits = char_traits<charT>>using basic_string = std::basic_string<charT, traits, polymorphic_allocator<charT>>; using string = basic_string<char>; using u8string = basic_string<char8_t>; using u16string = basic_string<char16_t>; using u32string = basic_string<char32_t>; using wstring = basic_string<wchar_t>; }// [[basic.string.hash]](basic.string.hash "27.4.6 Hash support"), hash supporttemplate<class T> struct hash; template<class A> struct hash<basic_string<char, char_traits<char>, A>>; template<class A> struct hash<basic_string<char8_t, char_traits<char8_t>, A>>; template<class A> struct hash<basic_string<char16_t, char_traits<char16_t>, A>>; template<class A> struct hash<basic_string<char32_t, char_traits<char32_t>, A>>; template<class A> struct hash<basic_string<wchar_t, char_traits<wchar_t>, A>>; inline namespace literals {inline namespace string_literals {// [[basic.string.literals]](basic.string.literals "27.4.7 Suffix for basic_string literals"), suffix for basic_string literalsconstexpr string operator""s(const char* str, size_t len); constexpr u8string operator""s(const char8_t* str, size_t len); constexpr u16string operator""s(const char16_t* str, size_t len); constexpr u32string operator""s(const char32_t* str, size_t len); constexpr wstring operator""s(const wchar_t* str, size_t len); }}}
|
||||
1252
cppdraft/string/view.md
Normal file
1252
cppdraft/string/view.md
Normal file
File diff suppressed because it is too large
Load Diff
124
cppdraft/string/view/access.md
Normal file
124
cppdraft/string/view/access.md
Normal file
@@ -0,0 +1,124 @@
|
||||
[string.view.access]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#access)
|
||||
|
||||
### 27.3.3 Class template basic_string_view [[string.view.template]](string.view.template#string.view.access)
|
||||
|
||||
#### 27.3.3.6 Element access [string.view.access]
|
||||
|
||||
[ð](#lib:operator%5b%5d,basic_string_view)
|
||||
|
||||
`constexpr const_reference operator[](size_type pos) const;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1042)
|
||||
|
||||
*Hardened preconditions*: pos < size() is true[.](#1.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
This precondition is stronger than the one on basic_string::operator[][.](#1.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1049)
|
||||
|
||||
*Returns*: *data_*[pos][.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1053)
|
||||
|
||||
*Throws*: Nothing[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:at,basic_string_view)
|
||||
|
||||
`constexpr const_reference at(size_type pos) const;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1064)
|
||||
|
||||
*Returns*: *data_*[pos][.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1068)
|
||||
|
||||
*Throws*: out_of_range if pos >= size()[.](#5.sentence-1)
|
||||
|
||||
[ð](#lib:front,basic_string_view)
|
||||
|
||||
`constexpr const_reference front() const;
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1079)
|
||||
|
||||
*Hardened preconditions*: empty() is false[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1083)
|
||||
|
||||
*Returns*: *data_*[0][.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1087)
|
||||
|
||||
*Throws*: Nothing[.](#8.sentence-1)
|
||||
|
||||
[ð](#lib:back,basic_string_view)
|
||||
|
||||
`constexpr const_reference back() const;
|
||||
`
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1098)
|
||||
|
||||
*Hardened preconditions*: empty() is false[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1102)
|
||||
|
||||
*Returns*: *data_*[size() - 1][.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1106)
|
||||
|
||||
*Throws*: Nothing[.](#11.sentence-1)
|
||||
|
||||
[ð](#lib:data,basic_string_view)
|
||||
|
||||
`constexpr const_pointer data() const noexcept;
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1117)
|
||||
|
||||
*Returns*: *data_*[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1121)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
Unlike basic_string::data() and [*string-literal*](lex.string#nt:string-literal "5.13.5 String literals [lex.string]")*s*,data() can return a pointer to a buffer that is not null-terminated[.](#13.sentence-1)
|
||||
|
||||
Therefore it is typically a mistake to pass data() to a function that takes just a const charT* and expects a null-terminated string[.](#13.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
43
cppdraft/string/view/capacity.md
Normal file
43
cppdraft/string/view/capacity.md
Normal file
@@ -0,0 +1,43 @@
|
||||
[string.view.capacity]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#capacity)
|
||||
|
||||
### 27.3.3 Class template basic_string_view [[string.view.template]](string.view.template#string.view.capacity)
|
||||
|
||||
#### 27.3.3.5 Capacity [string.view.capacity]
|
||||
|
||||
[ð](#lib:size,basic_string_view)
|
||||
|
||||
`constexpr size_type size() const noexcept;
|
||||
constexpr size_type length() const noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1006)
|
||||
|
||||
*Returns*: *size_*[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:max_size,basic_string_view)
|
||||
|
||||
`constexpr size_type max_size() const noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1018)
|
||||
|
||||
*Returns*: The largest possible number of char-like objects that can be referred to by a basic_string_view[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:empty,basic_string_view)
|
||||
|
||||
`constexpr bool empty() const noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1029)
|
||||
|
||||
*Returns*: *size_* == 0[.](#3.sentence-1)
|
||||
60
cppdraft/string/view/comparison.md
Normal file
60
cppdraft/string/view/comparison.md
Normal file
@@ -0,0 +1,60 @@
|
||||
[string.view.comparison]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#comparison)
|
||||
|
||||
### 27.3.4 Non-member comparison functions [string.view.comparison]
|
||||
|
||||
[ð](#lib:operator==,basic_string_view)
|
||||
|
||||
`template<class charT, class traits>
|
||||
constexpr bool operator==(basic_string_view<charT, traits> lhs,
|
||||
type_identity_t<basic_string_view<charT, traits>> rhs) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1610)
|
||||
|
||||
*Returns*: lhs.compare(rhs) == 0[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:operator%3c=%3e,basic_string_view)
|
||||
|
||||
`template<class charT, class traits>
|
||||
constexpr see below operator<=>(basic_string_view<charT, traits> lhs,
|
||||
type_identity_t<basic_string_view<charT, traits>> rhs) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1623)
|
||||
|
||||
Let R denote the type traits::comparison_category if
|
||||
that [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]") is valid and denotes a type ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction")),
|
||||
otherwise R is weak_ordering[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1628)
|
||||
|
||||
*Mandates*: R denotes a comparison category type ([[cmp.categories]](cmp.categories "17.12.2 Comparison category types"))[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1632)
|
||||
|
||||
*Returns*: static_cast<R>(lhs.compare(rhs) <=> 0)[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1636)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The usage of type_identity_t as parameter
|
||||
ensures that an object of type basic_string_view<charT, traits> can always be compared with an object of a type T with
|
||||
an implicit conversion to basic_string_view<charT, traits>, and
|
||||
vice versa, as per [[over.match.oper]](over.match.oper "12.2.2.3 Operators in expressions")[.](#5.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
169
cppdraft/string/view/cons.md
Normal file
169
cppdraft/string/view/cons.md
Normal file
@@ -0,0 +1,169 @@
|
||||
[string.view.cons]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#cons)
|
||||
|
||||
### 27.3.3 Class template basic_string_view [[string.view.template]](string.view.template#string.view.cons)
|
||||
|
||||
#### 27.3.3.2 Construction and assignment [string.view.cons]
|
||||
|
||||
[ð](#lib:basic_string_view,constructor)
|
||||
|
||||
`constexpr basic_string_view() noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L781)
|
||||
|
||||
*Postconditions*: *size_* == 0 and *data_* == nullptr[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string_view,constructor_)
|
||||
|
||||
`constexpr basic_string_view(const charT* str);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L792)
|
||||
|
||||
*Preconditions*: [str, str + traits::length(str)) is a valid range[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L796)
|
||||
|
||||
*Effects*: Constructs a basic_string_view, initializing *data_* with str and initializing *size_* with traits::length(str)[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L801)
|
||||
|
||||
*Complexity*: O(traits::length(str))[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string_view,constructor__)
|
||||
|
||||
`constexpr basic_string_view(const charT* str, size_type len);
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L812)
|
||||
|
||||
*Preconditions*: [str, str + len) is a valid range[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L816)
|
||||
|
||||
*Effects*: Constructs a basic_string_view, initializing *data_* with str and initializing *size_* with len[.](#6.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string_view,constructor___)
|
||||
|
||||
`template<class It, class End>
|
||||
constexpr basic_string_view(It begin, End end);
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L829)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(7.1)](#7.1)
|
||||
|
||||
It satisfies [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]")[.](#7.1.sentence-1)
|
||||
|
||||
- [(7.2)](#7.2)
|
||||
|
||||
End satisfies [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<It>[.](#7.2.sentence-1)
|
||||
|
||||
- [(7.3)](#7.3)
|
||||
|
||||
is_same_v<iter_value_t<It>, charT> is true[.](#7.3.sentence-1)
|
||||
|
||||
- [(7.4)](#7.4)
|
||||
|
||||
is_convertible_v<End, size_type> is false[.](#7.4.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L838)
|
||||
|
||||
*Preconditions*:
|
||||
|
||||
- [(8.1)](#8.1)
|
||||
|
||||
[begin, end) is a valid range[.](#8.1.sentence-1)
|
||||
|
||||
- [(8.2)](#8.2)
|
||||
|
||||
It models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]")[.](#8.2.sentence-1)
|
||||
|
||||
- [(8.3)](#8.3)
|
||||
|
||||
End models [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<It>[.](#8.3.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L846)
|
||||
|
||||
*Effects*: Initializes *data_* with to_address(begin) and
|
||||
initializes *size_* with end - begin[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L851)
|
||||
|
||||
*Throws*: When and what end - begin throws[.](#10.sentence-1)
|
||||
|
||||
[ð](#lib:basic_string_view,constructor____)
|
||||
|
||||
`template<class R>
|
||||
constexpr explicit basic_string_view(R&& r);
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L863)
|
||||
|
||||
Let d be an lvalue of type remove_cvref_t<R>[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L866)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(12.1)](#12.1)
|
||||
|
||||
remove_cvref_t<R> is not the same type as basic_string_view,
|
||||
|
||||
- [(12.2)](#12.2)
|
||||
|
||||
R modelsranges::[contiguous_range](range.refinements#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]") and ranges::[sized_range](range.sized#concept:sized_range "25.4.4 Sized ranges [range.sized]"),
|
||||
|
||||
- [(12.3)](#12.3)
|
||||
|
||||
is_same_v<ranges::range_value_t<R>, charT> is true,
|
||||
|
||||
- [(12.4)](#12.4)
|
||||
|
||||
is_convertible_v<R, const charT*> is false, and
|
||||
|
||||
- [(12.5)](#12.5)
|
||||
|
||||
d.operator ::std::basic_string_view<charT, traits>() is not a valid expression[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L883)
|
||||
|
||||
*Effects*: Initializes *data_* with ranges::data(r) and*size_* with ranges::size(r)[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L888)
|
||||
|
||||
*Throws*: Any exception thrown by ranges::data(r) and ranges::size(r)[.](#14.sentence-1)
|
||||
41
cppdraft/string/view/deduct.md
Normal file
41
cppdraft/string/view/deduct.md
Normal file
@@ -0,0 +1,41 @@
|
||||
[string.view.deduct]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#deduct)
|
||||
|
||||
### 27.3.3 Class template basic_string_view [[string.view.template]](string.view.template#string.view.deduct)
|
||||
|
||||
#### 27.3.3.3 Deduction guides [string.view.deduct]
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`template<class It, class End>
|
||||
basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L901)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
It satisfies [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]")[.](#1.1.sentence-1)
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
End satisfies [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<It>[.](#1.2.sentence-1)
|
||||
|
||||
[ð](#itemdecl:2)
|
||||
|
||||
`template<class R>
|
||||
basic_string_view(R&&) -> basic_string_view<ranges::range_value_t<R>>;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L915)
|
||||
|
||||
*Constraints*: R satisfies ranges::[contiguous_range](range.refinements#concept:contiguous_range "25.4.6 Other range refinements [range.refinements]")[.](#2.sentence-1)
|
||||
257
cppdraft/string/view/find.md
Normal file
257
cppdraft/string/view/find.md
Normal file
@@ -0,0 +1,257 @@
|
||||
[string.view.find]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#find)
|
||||
|
||||
### 27.3.3 Class template basic_string_view [[string.view.template]](string.view.template#string.view.find)
|
||||
|
||||
#### 27.3.3.9 Searching [string.view.find]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1403)
|
||||
|
||||
Member functions in this subclause have complexity O(size() * str.size()) at worst,
|
||||
although implementations should do better[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1407)
|
||||
|
||||
Let *F* be one offind,rfind,find_first_of,find_last_of,find_first_not_of,
|
||||
andfind_last_not_of[.](#2.sentence-1)
|
||||
|
||||
- [(2.1)](#2.1)
|
||||
|
||||
Each member function of the formconstexpr *return-type* *F*(const charT* s, size_type pos) const; has effects equivalent to: return *F*(basic_string_view(s), pos);
|
||||
|
||||
- [(2.2)](#2.2)
|
||||
|
||||
Each member function of the formconstexpr *return-type* *F*(const charT* s, size_type pos, size_type n) const; has effects equivalent to: return *F*(basic_string_view(s, n), pos);
|
||||
|
||||
- [(2.3)](#2.3)
|
||||
|
||||
Each member function of the formconstexpr *return-type* *F*(charT c, size_type pos) const noexcept; has effects equivalent to: return *F*(basic_string_view(addressof(c), 1), pos);
|
||||
|
||||
[ð](#lib:find,basic_string_view)
|
||||
|
||||
`constexpr size_type find(basic_string_view str, size_type pos = 0) const noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1445)
|
||||
|
||||
Let xpos be the lowest position, if possible, such that the following conditions hold:
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
pos <= xpos
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
xpos + str.size() <= size()
|
||||
|
||||
- [(3.3)](#3.3)
|
||||
|
||||
traits::eq(*data_*[xpos + I], str[I]) for all elements I of the string referenced by str[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1456)
|
||||
|
||||
*Effects*: Determines xpos[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1460)
|
||||
|
||||
*Returns*: xpos if the function can determine such a value for xpos[.](#5.sentence-1)
|
||||
|
||||
Otherwise, returns npos[.](#5.sentence-2)
|
||||
|
||||
[ð](#lib:rfind,basic_string_view)
|
||||
|
||||
`constexpr size_type rfind(basic_string_view str, size_type pos = npos) const noexcept;
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1472)
|
||||
|
||||
Let xpos be the highest position, if possible, such that the following conditions hold:
|
||||
|
||||
- [(6.1)](#6.1)
|
||||
|
||||
xpos <= pos
|
||||
|
||||
- [(6.2)](#6.2)
|
||||
|
||||
xpos + str.size() <= size()
|
||||
|
||||
- [(6.3)](#6.3)
|
||||
|
||||
traits::eq(*data_*[xpos + I], str[I]) for all elements I of the string referenced by str[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1483)
|
||||
|
||||
*Effects*: Determines xpos[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1487)
|
||||
|
||||
*Returns*: xpos if the function can determine such a value for xpos[.](#8.sentence-1)
|
||||
|
||||
Otherwise, returns npos[.](#8.sentence-2)
|
||||
|
||||
[ð](#lib:find_first_of,basic_string_view)
|
||||
|
||||
`constexpr size_type find_first_of(basic_string_view str, size_type pos = 0) const noexcept;
|
||||
`
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1499)
|
||||
|
||||
Let xpos be the lowest position, if possible, such that the following conditions hold:
|
||||
|
||||
- [(9.1)](#9.1)
|
||||
|
||||
pos <= xpos
|
||||
|
||||
- [(9.2)](#9.2)
|
||||
|
||||
xpos < size()
|
||||
|
||||
- [(9.3)](#9.3)
|
||||
|
||||
traits::eq(*data_*[xpos], str[I]) for some element I of the string referenced by str[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1510)
|
||||
|
||||
*Effects*: Determines xpos[.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1514)
|
||||
|
||||
*Returns*: xpos if the function can determine such a value for xpos[.](#11.sentence-1)
|
||||
|
||||
Otherwise, returns npos[.](#11.sentence-2)
|
||||
|
||||
[ð](#lib:find_last_of,basic_string_view)
|
||||
|
||||
`constexpr size_type find_last_of(basic_string_view str, size_type pos = npos) const noexcept;
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1526)
|
||||
|
||||
Let xpos be the highest position, if possible, such that the following conditions hold:
|
||||
|
||||
- [(12.1)](#12.1)
|
||||
|
||||
xpos <= pos
|
||||
|
||||
- [(12.2)](#12.2)
|
||||
|
||||
xpos < size()
|
||||
|
||||
- [(12.3)](#12.3)
|
||||
|
||||
traits::eq(*data_*[xpos], str[I]) for some element I of the string referenced by str[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1537)
|
||||
|
||||
*Effects*: Determines xpos[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1541)
|
||||
|
||||
*Returns*: xpos if the function can determine such a value for xpos[.](#14.sentence-1)
|
||||
|
||||
Otherwise, returns npos[.](#14.sentence-2)
|
||||
|
||||
[ð](#lib:find_first_not_of,basic_string_view)
|
||||
|
||||
`constexpr size_type find_first_not_of(basic_string_view str, size_type pos = 0) const noexcept;
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1553)
|
||||
|
||||
Let xpos be the lowest position, if possible, such that the following conditions hold:
|
||||
|
||||
- [(15.1)](#15.1)
|
||||
|
||||
pos <= xpos
|
||||
|
||||
- [(15.2)](#15.2)
|
||||
|
||||
xpos < size()
|
||||
|
||||
- [(15.3)](#15.3)
|
||||
|
||||
traits::eq(*data_*[xpos], str[I]) for no element I of the string referenced by str[.](#15.sentence-1)
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1564)
|
||||
|
||||
*Effects*: Determines xpos[.](#16.sentence-1)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1568)
|
||||
|
||||
*Returns*: xpos if the function can determine such a value for xpos[.](#17.sentence-1)
|
||||
|
||||
Otherwise, returns npos[.](#17.sentence-2)
|
||||
|
||||
[ð](#lib:find_last_not_of,basic_string_view)
|
||||
|
||||
`constexpr size_type find_last_not_of(basic_string_view str, size_type pos = npos) const noexcept;
|
||||
`
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1579)
|
||||
|
||||
Let xpos be the highest position, if possible, such that the following conditions hold:
|
||||
|
||||
- [(18.1)](#18.1)
|
||||
|
||||
xpos <= pos
|
||||
|
||||
- [(18.2)](#18.2)
|
||||
|
||||
xpos < size()
|
||||
|
||||
- [(18.3)](#18.3)
|
||||
|
||||
traits::eq(*data_*[xpos], str[I]) for no element I of the string referenced by str[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1590)
|
||||
|
||||
*Effects*: Determines xpos[.](#19.sentence-1)
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1594)
|
||||
|
||||
*Returns*: xpos if the function can determine such a value for xpos[.](#20.sentence-1)
|
||||
|
||||
Otherwise, returns npos[.](#20.sentence-2)
|
||||
27
cppdraft/string/view/general.md
Normal file
27
cppdraft/string/view/general.md
Normal file
@@ -0,0 +1,27 @@
|
||||
[string.view.general]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#general)
|
||||
|
||||
### 27.3.1 General [string.view.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L521)
|
||||
|
||||
The class template basic_string_view describes an object that can refer to a constant contiguous sequence of char-like ([[strings.general]](strings.general "27.1 General")) objects with the first element of the sequence at position zero[.](#1.sentence-1)
|
||||
|
||||
In the rest of [[string.view]](string.view "27.3 String view classes"), the type of the char-like objects held in a basic_string_view object is designated by charT[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L525)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The library provides implicit conversions from const charT* and std::basic_string<charT, ...> to std::basic_string_view<charT, ...> so that user code can accept just std::basic_string_view<charT> as a non-templated parameter wherever a sequence of characters is expected[.](#2.sentence-1)
|
||||
|
||||
User-defined types can define their own implicit conversions to std::basic_string_view<charT> in order to interoperate with these functions[.](#2.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
29
cppdraft/string/view/hash.md
Normal file
29
cppdraft/string/view/hash.md
Normal file
@@ -0,0 +1,29 @@
|
||||
[string.view.hash]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#hash)
|
||||
|
||||
### 27.3.6 Hash support [string.view.hash]
|
||||
|
||||
[ð](#lib:hash,string_view)
|
||||
|
||||
`template<> struct hash<string_view>;
|
||||
template<> struct hash<u8string_view>;
|
||||
template<> struct hash<u16string_view>;
|
||||
template<> struct hash<u32string_view>;
|
||||
template<> struct hash<wstring_view>;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1689)
|
||||
|
||||
The specialization is enabled ([[unord.hash]](unord.hash "22.10.19 Class template hash"))[.](#1.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The hash value of a string view object is equal to the hash value of
|
||||
the corresponding string object ([[basic.string.hash]](basic.string.hash "27.4.6 Hash support"))[.](#1.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
36
cppdraft/string/view/io.md
Normal file
36
cppdraft/string/view/io.md
Normal file
@@ -0,0 +1,36 @@
|
||||
[string.view.io]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#io)
|
||||
|
||||
### 27.3.5 Inserters and extractors [string.view.io]
|
||||
|
||||
[ð](#lib:operator%3c%3c,basic_string_view)
|
||||
|
||||
`template<class charT, class traits>
|
||||
basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os, basic_string_view<charT, traits> str);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1656)
|
||||
|
||||
*Effects*: Behaves as a formatted output
|
||||
function ([[ostream.formatted.reqmts]](ostream.formatted.reqmts "31.7.6.3.1 Common requirements")) of os[.](#1.sentence-1)
|
||||
|
||||
Forms a character sequenceseq, initially consisting of the elements defined by the range
|
||||
[str.begin(), str.end())[.](#1.sentence-2)
|
||||
|
||||
Determines padding for seq as described in [[ostream.formatted.reqmts]](ostream.formatted.reqmts "31.7.6.3.1 Common requirements")[.](#1.sentence-3)
|
||||
|
||||
Then inserts seq as if by callingos.rdbuf()->sputn(seq, n), where n is the larger
|
||||
of os.width() and str.size();
|
||||
then calls os.width(0)[.](#1.sentence-4)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1668)
|
||||
|
||||
*Returns*: os[.](#2.sentence-1)
|
||||
86
cppdraft/string/view/iterators.md
Normal file
86
cppdraft/string/view/iterators.md
Normal file
@@ -0,0 +1,86 @@
|
||||
[string.view.iterators]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#iterators)
|
||||
|
||||
### 27.3.3 Class template basic_string_view [[string.view.template]](string.view.template#string.view.iterators)
|
||||
|
||||
#### 27.3.3.4 Iterator support [string.view.iterators]
|
||||
|
||||
[ð](#lib:const_iterator,basic_string_view)
|
||||
|
||||
`using const_iterator = implementation-defined;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L928)
|
||||
|
||||
A type that meets the requirements
|
||||
of a constant[*Cpp17RandomAccessIterator*](random.access.iterators#:Cpp17RandomAccessIterator "24.3.5.7 Random access iterators [random.access.iterators]") ([[random.access.iterators]](random.access.iterators "24.3.5.7 Random access iterators")),
|
||||
models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]") ([[iterator.concept.contiguous]](iterator.concept.contiguous "24.3.4.14 Concept contiguous_iterator")), and
|
||||
meets the constexpr iterator requirements ([[iterator.requirements.general]](iterator.requirements.general "24.3.1 General")),
|
||||
whose value_type is the template parameter charT[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L936)
|
||||
|
||||
All requirements on container iterators ([[container.requirements]](container.requirements "23.2 Requirements")) apply to basic_string_view::const_iterator as well[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:begin,basic_string_view)
|
||||
|
||||
`constexpr const_iterator begin() const noexcept;
|
||||
constexpr const_iterator cbegin() const noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L948)
|
||||
|
||||
*Returns*: An iterator such that
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
if !empty(), addressof(*begin()) == *data_*,
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
otherwise, an unspecified value such that [begin(), end()) is a valid range[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:end,basic_string_view)
|
||||
|
||||
`constexpr const_iterator end() const noexcept;
|
||||
constexpr const_iterator cend() const noexcept;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L965)
|
||||
|
||||
*Returns*: begin() + size()[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:rbegin,basic_string_view)
|
||||
|
||||
`constexpr const_reverse_iterator rbegin() const noexcept;
|
||||
constexpr const_reverse_iterator crbegin() const noexcept;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L978)
|
||||
|
||||
*Returns*: const_reverse_iterator(end())[.](#5.sentence-1)
|
||||
|
||||
[ð](#lib:rend,basic_string_view)
|
||||
|
||||
`constexpr const_reverse_iterator rend() const noexcept;
|
||||
constexpr const_reverse_iterator crend() const noexcept;
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L991)
|
||||
|
||||
*Returns*: const_reverse_iterator(begin())[.](#6.sentence-1)
|
||||
62
cppdraft/string/view/literals.md
Normal file
62
cppdraft/string/view/literals.md
Normal file
@@ -0,0 +1,62 @@
|
||||
[string.view.literals]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#literals)
|
||||
|
||||
### 27.3.7 Suffix for basic_string_view literals [string.view.literals]
|
||||
|
||||
[ð](#lib:operator%22%22sv,string_view)
|
||||
|
||||
`constexpr string_view operator""sv(const char* str, size_t len) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1705)
|
||||
|
||||
*Returns*: string_view{str, len}[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:operator%22%22sv,u8string_view)
|
||||
|
||||
`constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1715)
|
||||
|
||||
*Returns*: u8string_view{str, len}[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:operator%22%22sv,u16string_view)
|
||||
|
||||
`constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1725)
|
||||
|
||||
*Returns*: u16string_view{str, len}[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:operator%22%22sv,u32string_view)
|
||||
|
||||
`constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1735)
|
||||
|
||||
*Returns*: u32string_view{str, len}[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:operator%22%22sv,wstring_view)
|
||||
|
||||
`constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1745)
|
||||
|
||||
*Returns*: wstring_view{str, len}[.](#5.sentence-1)
|
||||
54
cppdraft/string/view/modifiers.md
Normal file
54
cppdraft/string/view/modifiers.md
Normal file
@@ -0,0 +1,54 @@
|
||||
[string.view.modifiers]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#modifiers)
|
||||
|
||||
### 27.3.3 Class template basic_string_view [[string.view.template]](string.view.template#string.view.modifiers)
|
||||
|
||||
#### 27.3.3.7 Modifiers [string.view.modifiers]
|
||||
|
||||
[ð](#lib:remove_prefix,basic_string_view)
|
||||
|
||||
`constexpr void remove_prefix(size_type n);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1137)
|
||||
|
||||
*Hardened preconditions*: n <= size() is true[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1141)
|
||||
|
||||
*Effects*: Equivalent to: *data_* += n; *size_* -= n;
|
||||
|
||||
[ð](#lib:remove_suffix,basic_string_view)
|
||||
|
||||
`constexpr void remove_suffix(size_type n);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1152)
|
||||
|
||||
*Hardened preconditions*: n <= size() is true[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1156)
|
||||
|
||||
*Effects*: Equivalent to: *size_* -= n;
|
||||
|
||||
[ð](#lib:swap,basic_string_view)
|
||||
|
||||
`constexpr void swap(basic_string_view& s) noexcept;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1167)
|
||||
|
||||
*Effects*: Exchanges the values of *this and s[.](#5.sentence-1)
|
||||
268
cppdraft/string/view/ops.md
Normal file
268
cppdraft/string/view/ops.md
Normal file
@@ -0,0 +1,268 @@
|
||||
[string.view.ops]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#ops)
|
||||
|
||||
### 27.3.3 Class template basic_string_view [[string.view.template]](string.view.template#string.view.ops)
|
||||
|
||||
#### 27.3.3.8 String operations [string.view.ops]
|
||||
|
||||
[ð](#lib:copy,basic_string_view)
|
||||
|
||||
`constexpr size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1180)
|
||||
|
||||
Let rlen be the smaller of n and size() - pos[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1183)
|
||||
|
||||
*Preconditions*: [s, s + rlen) is a valid range[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1187)
|
||||
|
||||
*Effects*: Equivalent to traits::copy(s, data() + pos, rlen)[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1191)
|
||||
|
||||
*Returns*: rlen[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1195)
|
||||
|
||||
*Throws*: out_of_range if pos > size()[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1199)
|
||||
|
||||
*Complexity*: O(rlen)[.](#6.sentence-1)
|
||||
|
||||
[ð](#lib:substr,basic_string_view)
|
||||
|
||||
`constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
|
||||
constexpr basic_string_view subview(size_type pos = 0, size_type n = npos) const;
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1212)
|
||||
|
||||
Let rlen be the smaller of n and size() - pos[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1215)
|
||||
|
||||
*Effects*: Determines rlen, the effective length of the string to reference[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1219)
|
||||
|
||||
*Returns*: basic_string_view(data() + pos, rlen)[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1223)
|
||||
|
||||
*Throws*: out_of_range if pos > size()[.](#10.sentence-1)
|
||||
|
||||
[ð](#lib:compare,basic_string_view)
|
||||
|
||||
`constexpr int compare(basic_string_view str) const noexcept;
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1234)
|
||||
|
||||
Let rlen be the smaller of size() and str.size()[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1237)
|
||||
|
||||
*Effects*: Determines rlen, the effective length of the strings to compare[.](#12.sentence-1)
|
||||
|
||||
The function then compares the two strings by calling traits::compare(data(), str.data(), rlen)[.](#12.sentence-2)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1242)
|
||||
|
||||
*Returns*: The nonzero result if the result of the comparison is nonzero[.](#13.sentence-1)
|
||||
|
||||
Otherwise, returns a value as indicated in Table [88](#tab:string.view.compare "Table 88: compare() results")[.](#13.sentence-2)
|
||||
|
||||
Table [88](#tab:string.view.compare) — compare() results [[tab:string.view.compare]](./tab:string.view.compare)
|
||||
|
||||
| [ð](#tab:string.view.compare-row-1)<br>**Condition** | **Return Value** |
|
||||
| --- | --- |
|
||||
| [ð](#tab:string.view.compare-row-2)<br>size() < str.size() | < 0 |
|
||||
| [ð](#tab:string.view.compare-row-3)<br>size() == str.size() | 0 |
|
||||
| [ð](#tab:string.view.compare-row-4)<br>size() > str.size() | > 0 |
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1252)
|
||||
|
||||
*Complexity*: O(rlen)[.](#14.sentence-1)
|
||||
|
||||
[ð](#lib:compare,basic_string_view_)
|
||||
|
||||
`constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1263)
|
||||
|
||||
*Effects*: Equivalent to: return substr(pos1, n1).compare(str);
|
||||
|
||||
[ð](#lib:compare,basic_string_view__)
|
||||
|
||||
`constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
|
||||
size_type pos2, size_type n2) const;
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1275)
|
||||
|
||||
*Effects*: Equivalent to: return substr(pos1, n1).compare(str.substr(pos2, n2));
|
||||
|
||||
[ð](#lib:compare,basic_string_view___)
|
||||
|
||||
`constexpr int compare(const charT* s) const;
|
||||
`
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1286)
|
||||
|
||||
*Effects*: Equivalent to: return compare(basic_string_view(s));
|
||||
|
||||
[ð](#lib:compare,basic_string_view____)
|
||||
|
||||
`constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
|
||||
`
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1297)
|
||||
|
||||
*Effects*: Equivalent to: return substr(pos1, n1).compare(basic_string_view(s));
|
||||
|
||||
[ð](#lib:compare,basic_string_view_____)
|
||||
|
||||
`constexpr int compare(size_type pos1, size_type n1, const charT* s, size_type n2) const;
|
||||
`
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1308)
|
||||
|
||||
*Effects*: Equivalent to: return substr(pos1, n1).compare(basic_string_view(s, n2));
|
||||
|
||||
[ð](#lib:starts_with,basic_string_view)
|
||||
|
||||
`constexpr bool starts_with(basic_string_view x) const noexcept;
|
||||
`
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1319)
|
||||
|
||||
Let rlen be the smaller of size() and x.size()[.](#20.sentence-1)
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1322)
|
||||
|
||||
*Effects*: Equivalent to: return basic_string_view(data(), rlen) == x;
|
||||
|
||||
[ð](#lib:starts_with,basic_string_view_)
|
||||
|
||||
`constexpr bool starts_with(charT x) const noexcept;
|
||||
`
|
||||
|
||||
[22](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1333)
|
||||
|
||||
*Effects*: Equivalent to: return !empty() && traits::eq(front(), x);
|
||||
|
||||
[ð](#lib:starts_with,basic_string_view__)
|
||||
|
||||
`constexpr bool starts_with(const charT* x) const;
|
||||
`
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1344)
|
||||
|
||||
*Effects*: Equivalent to: return starts_with(basic_string_view(x));
|
||||
|
||||
[ð](#lib:ends_with,basic_string_view)
|
||||
|
||||
`constexpr bool ends_with(basic_string_view x) const noexcept;
|
||||
`
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1355)
|
||||
|
||||
Let rlen be the smaller of size() and x.size()[.](#24.sentence-1)
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1358)
|
||||
|
||||
*Effects*: Equivalent to:return basic_string_view(data() + (size() - rlen), rlen) == x;
|
||||
|
||||
[ð](#lib:ends_with,basic_string_view_)
|
||||
|
||||
`constexpr bool ends_with(charT x) const noexcept;
|
||||
`
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1372)
|
||||
|
||||
*Effects*: Equivalent to: return !empty() && traits::eq(back(), x);
|
||||
|
||||
[ð](#lib:ends_with,basic_string_view__)
|
||||
|
||||
`constexpr bool ends_with(const charT* x) const;
|
||||
`
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1383)
|
||||
|
||||
*Effects*: Equivalent to: return ends_with(basic_string_view(x));
|
||||
|
||||
[ð](#lib:contains,basic_string_view)
|
||||
|
||||
`constexpr bool contains(basic_string_view x) const noexcept;
|
||||
constexpr bool contains(charT x) const noexcept;
|
||||
constexpr bool contains(const charT* x) const;
|
||||
`
|
||||
|
||||
[28](#28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L1396)
|
||||
|
||||
*Effects*: Equivalent to: return find(x) != npos;
|
||||
21
cppdraft/string/view/synop.md
Normal file
21
cppdraft/string/view/synop.md
Normal file
@@ -0,0 +1,21 @@
|
||||
[string.view.synop]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#synop)
|
||||
|
||||
### 27.3.2 Header <string_view> synopsis [string.view.synop]
|
||||
|
||||
[ð](#header:%3cstring_view%3e)
|
||||
|
||||
// mostly freestanding#include <compare> // see [[compare.syn]](compare.syn "17.12.1 Header <compare> synopsis")namespace std {// [[string.view.template]](string.view.template "27.3.3 Class template basic_string_view"), class template basic_string_viewtemplate<class charT, class traits = char_traits<charT>>class basic_string_view; // partially freestandingtemplate<class charT, class traits>constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true; template<class charT, class traits>constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true; // [[string.view.comparison]](string.view.comparison "27.3.4 Non-member comparison functions"), non-member comparison functionstemplate<class charT, class traits>constexpr bool operator==(basic_string_view<charT, traits> x,
|
||||
type_identity_t<basic_string_view<charT, traits>> y) noexcept; template<class charT, class traits>constexpr *see below* operator<=>(basic_string_view<charT, traits> x,
|
||||
type_identity_t<basic_string_view<charT,
|
||||
traits>> y) noexcept; // [[string.view.io]](string.view.io "27.3.5 Inserters and extractors"), inserters and extractorstemplate<class charT, class traits> basic_ostream<charT, traits>&operator<<(basic_ostream<charT, traits>& os,
|
||||
basic_string_view<charT, traits> str); // hosted// basic_string_view [*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4 The typedef specifier [dcl.typedef]")*s*using string_view = basic_string_view<char>; using u8string_view = basic_string_view<char8_t>; using u16string_view = basic_string_view<char16_t>; using u32string_view = basic_string_view<char32_t>; using wstring_view = basic_string_view<wchar_t>; // [[string.view.hash]](string.view.hash "27.3.6 Hash support"), hash supporttemplate<class T> struct hash; template<> struct hash<string_view>; template<> struct hash<u8string_view>; template<> struct hash<u16string_view>; template<> struct hash<u32string_view>; template<> struct hash<wstring_view>; inline namespace literals {inline namespace string_view_literals {// [[string.view.literals]](string.view.literals "27.3.7 Suffix for basic_string_view literals"), suffix for basic_string_view literalsconstexpr string_view operator""sv(const char* str, size_t len) noexcept; constexpr u8string_view operator""sv(const char8_t* str, size_t len) noexcept; constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept; constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept; constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept; }}}
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L591)
|
||||
|
||||
The function templates defined in [[utility.swap]](utility.swap "22.2.2 swap") and [[iterator.range]](iterator.range "24.7 Range access") are available when <string_view> is included[.](#1.sentence-1)
|
||||
1047
cppdraft/string/view/template.md
Normal file
1047
cppdraft/string/view/template.md
Normal file
File diff suppressed because it is too large
Load Diff
61
cppdraft/string/view/template/general.md
Normal file
61
cppdraft/string/view/template/general.md
Normal file
@@ -0,0 +1,61 @@
|
||||
[string.view.template.general]
|
||||
|
||||
# 27 Strings library [[strings]](./#strings)
|
||||
|
||||
## 27.3 String view classes [[string.view]](string.view#template.general)
|
||||
|
||||
### 27.3.3 Class template basic_string_view [[string.view.template]](string.view.template#general)
|
||||
|
||||
#### 27.3.3.1 General [string.view.template.general]
|
||||
|
||||
[ð](#lib:basic_string_view)
|
||||
|
||||
namespace std {template<class charT, class traits = char_traits<charT>>class basic_string_view {public:// typesusing traits_type = traits; using value_type = charT; using pointer = value_type*; using const_pointer = const value_type*; using reference = value_type&; using const_reference = const value_type&; using const_iterator = *implementation-defined*; // see [[string.view.iterators]](string.view.iterators "27.3.3.4 Iterator support")using iterator = const_iterator;[211](#footnote-211 "Because basic_string_view refers to a constant sequence, iterator and const_iterator are the same type.")using const_reverse_iterator = reverse_iterator<const_iterator>; using reverse_iterator = const_reverse_iterator; using size_type = size_t; using difference_type = ptrdiff_t; static constexpr size_type npos = size_type(-1); // [[string.view.cons]](string.view.cons "27.3.3.2 Construction and assignment"), construction and assignmentconstexpr basic_string_view() noexcept; constexpr basic_string_view(const basic_string_view&) noexcept = default; constexpr basic_string_view& operator=(const basic_string_view&) noexcept = default; constexpr basic_string_view(const charT* str);
|
||||
basic_string_view(nullptr_t) = delete; constexpr basic_string_view(const charT* str, size_type len); template<class It, class End>constexpr basic_string_view(It begin, End end); template<class R>constexpr explicit basic_string_view(R&& r); // [[string.view.iterators]](string.view.iterators "27.3.3.4 Iterator support"), iterator supportconstexpr const_iterator begin() const noexcept; constexpr const_iterator end() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; constexpr const_reverse_iterator rbegin() const noexcept; constexpr const_reverse_iterator rend() const noexcept; constexpr const_reverse_iterator crbegin() const noexcept; constexpr const_reverse_iterator crend() const noexcept; // [[string.view.capacity]](string.view.capacity "27.3.3.5 Capacity"), capacityconstexpr size_type size() const noexcept; constexpr size_type length() const noexcept; constexpr size_type max_size() const noexcept; constexpr bool empty() const noexcept; // [[string.view.access]](string.view.access "27.3.3.6 Element access"), element accessconstexpr const_reference operator[](size_type pos) const; constexpr const_reference at(size_type pos) const; // freestanding-deletedconstexpr const_reference front() const; constexpr const_reference back() const; constexpr const_pointer data() const noexcept; // [[string.view.modifiers]](string.view.modifiers "27.3.3.7 Modifiers"), modifiersconstexpr void remove_prefix(size_type n); constexpr void remove_suffix(size_type n); constexpr void swap(basic_string_view& s) noexcept; // [[string.view.ops]](string.view.ops "27.3.3.8 String operations"), string operationsconstexpr size_type copy(charT* s, size_type n,
|
||||
size_type pos = 0) const; // freestanding-deletedconstexpr basic_string_view substr(size_type pos = 0,
|
||||
size_type n = npos) const; // freestanding-deletedconstexpr basic_string_view subview(size_type pos = 0,
|
||||
size_type n = npos) const; // freestanding-deletedconstexpr int compare(basic_string_view s) const noexcept; constexpr int compare(size_type pos1, size_type n1,
|
||||
basic_string_view s) const; // freestanding-deletedconstexpr int compare(size_type pos1, size_type n1, basic_string_view s,
|
||||
size_type pos2, size_type n2) const; // freestanding-deletedconstexpr int compare(const charT* s) const; constexpr int compare(size_type pos1, size_type n1, const charT* s) const; // freestanding-deletedconstexpr int compare(size_type pos1, size_type n1, const charT* s,
|
||||
size_type n2) const; // freestanding-deletedconstexpr bool starts_with(basic_string_view x) const noexcept; constexpr bool starts_with(charT x) const noexcept; constexpr bool starts_with(const charT* x) const; constexpr bool ends_with(basic_string_view x) const noexcept; constexpr bool ends_with(charT x) const noexcept; constexpr bool ends_with(const charT* x) const; constexpr bool contains(basic_string_view x) const noexcept; constexpr bool contains(charT x) const noexcept; constexpr bool contains(const charT* x) const; // [[string.view.find]](string.view.find "27.3.3.9 Searching"), searchingconstexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept; constexpr size_type find(charT c, size_type pos = 0) const noexcept; constexpr size_type find(const charT* s, size_type pos, size_type n) const; constexpr size_type find(const charT* s, size_type pos = 0) const; constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept; constexpr size_type rfind(charT c, size_type pos = npos) const noexcept; constexpr size_type rfind(const charT* s, size_type pos, size_type n) const; constexpr size_type rfind(const charT* s, size_type pos = npos) const; constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept; constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept; constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const; constexpr size_type find_first_of(const charT* s, size_type pos = 0) const; constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept; constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept; constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const; constexpr size_type find_last_of(const charT* s, size_type pos = npos) const; constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept; constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept; constexpr size_type find_first_not_of(const charT* s, size_type pos,
|
||||
size_type n) const; constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const; constexpr size_type find_last_not_of(basic_string_view s,
|
||||
size_type pos = npos) const noexcept; constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept; constexpr size_type find_last_not_of(const charT* s, size_type pos,
|
||||
size_type n) const; constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const; private: const_pointer *data_*; // *exposition only* size_type *size_*; // *exposition only*}; // [[string.view.deduct]](string.view.deduct "27.3.3.3 Deduction guides"), deduction guidestemplate<class It, class End> basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>; template<class R> basic_string_view(R&&) -> basic_string_view<ranges::range_value_t<R>>;}
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L749)
|
||||
|
||||
In every specialization basic_string_view<charT, traits>, the type traits shall meet the character traits requirements ([[char.traits]](char.traits "27.2 Character traits"))[.](#1.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The program is ill-formed if traits::char_type is not the same type as charT[.](#1.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L755)
|
||||
|
||||
For a basic_string_view str,
|
||||
any operation that invalidates a pointer
|
||||
in the range[str.data(), str.data() + str.size()) invalidates pointers, iterators, and references
|
||||
to elements of str[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L765)
|
||||
|
||||
The complexity of basic_string_view member functions is O(1) unless otherwise specified[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L769)
|
||||
|
||||
basic_string_view<charT, traits> is
|
||||
a trivially copyable type ([[basic.types.general]](basic.types.general#term.trivially.copyable.type "6.9.1 General"))[.](#4.sentence-1)
|
||||
|
||||
[211)](#footnote-211)[211)](#footnoteref-211)
|
||||
|
||||
Because basic_string_view refers to a constant sequence, iterator and const_iterator are the same type[.](#footnote-211.sentence-1)
|
||||
Reference in New Issue
Block a user