This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View 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.5String 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*]

View 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)

View 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.3Qualified names[expr.prim.id.qual]") is valid and denotes a type ([[temp.deduct]](temp.deduct "13.10.3Template 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.2Comparison 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.3Operators in expressions")[.](#5.sentence-1)
— *end note*]

View 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.14Concept 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.8Concept 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.14Concept 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.8Concept 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.6Other range refinements[range.refinements]") and ranges::[sized_range](range.sized#concept:sized_range "25.4.4Sized 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)

View 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.14Concept 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.8Concept 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.6Other range refinements[range.refinements]")[.](#2.sentence-1)

View 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)

View 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.1General")) objects with the first element of the sequence at position zero[.](#1.sentence-1)
In the rest of [[string.view]](string.view "27.3String 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*]

View 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.19Class 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.6Hash support"))[.](#1.sentence-2)
— *end note*]

View 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.1Common 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.1Common 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)

View 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.7Random access iterators[random.access.iterators]") ([[random.access.iterators]](random.access.iterators "24.3.5.7Random access iterators")),
models [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14Concept contiguous_­iterator[iterator.concept.contiguous]") ([[iterator.concept.contiguous]](iterator.concept.contiguous "24.3.4.14Concept contiguous_­iterator")), and
meets the constexpr iterator requirements ([[iterator.requirements.general]](iterator.requirements.general "24.3.1General")),
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.2Requirements")) 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)

View 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)

View 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
View 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;

View 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.1Header <compare> synopsis")namespace std {// [[string.view.template]](string.view.template "27.3.3Class 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.4Non-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.5Inserters 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.4The 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.6Hash 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.7Suffix 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.2swap") and [[iterator.range]](iterator.range "24.7Range access") are available when <string_view> is included[.](#1.sentence-1)

File diff suppressed because it is too large Load Diff

View 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.4Iterator 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.2Construction 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.4Iterator 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.5Capacity"), 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.6Element 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.7Modifiers"), 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.8String 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.9Searching"), 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.3Deduction 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.2Character 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.1General"))[.](#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)