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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## String view classes <a id="string.view">[[string.view]]</a>
|
| 2 |
+
|
| 3 |
+
The class template `basic_string_view` describes an object that can
|
| 4 |
+
refer to a constant contiguous sequence of char-like (
|
| 5 |
+
[[strings.general]]) objects with the first element of the sequence at
|
| 6 |
+
position zero. In the rest of this section, the type of the char-like
|
| 7 |
+
objects held in a `basic_string_view` object is designated by `charT`.
|
| 8 |
+
|
| 9 |
+
[*Note 1*: The library provides implicit conversions from
|
| 10 |
+
`const charT*` and `std::basic_string<charT, ...>` to
|
| 11 |
+
`std::basic_string_view<charT, ...>` so that user code can accept just
|
| 12 |
+
`std::basic_string_view<charT>` as a non-templated parameter wherever a
|
| 13 |
+
sequence of characters is expected. User-defined types should define
|
| 14 |
+
their own implicit conversions to `std::basic_string_view` in order to
|
| 15 |
+
interoperate with these functions. — *end note*]
|
| 16 |
+
|
| 17 |
+
The complexity of `basic_string_view` member functions is 𝑂(1) unless
|
| 18 |
+
otherwise specified.
|
| 19 |
+
|
| 20 |
+
### Header `<string_view>` synopsis <a id="string.view.synop">[[string.view.synop]]</a>
|
| 21 |
+
|
| 22 |
+
``` cpp
|
| 23 |
+
namespace std {
|
| 24 |
+
// [string.view.template], class template basic_string_view
|
| 25 |
+
template<class charT, class traits = char_traits<charT>>
|
| 26 |
+
class basic_string_view;
|
| 27 |
+
|
| 28 |
+
// [string.view.comparison], non-member comparison functions
|
| 29 |
+
template<class charT, class traits>
|
| 30 |
+
constexpr bool operator==(basic_string_view<charT, traits> x,
|
| 31 |
+
basic_string_view<charT, traits> y) noexcept;
|
| 32 |
+
template<class charT, class traits>
|
| 33 |
+
constexpr bool operator!=(basic_string_view<charT, traits> x,
|
| 34 |
+
basic_string_view<charT, traits> y) noexcept;
|
| 35 |
+
template<class charT, class traits>
|
| 36 |
+
constexpr bool operator< (basic_string_view<charT, traits> x,
|
| 37 |
+
basic_string_view<charT, traits> y) noexcept;
|
| 38 |
+
template<class charT, class traits>
|
| 39 |
+
constexpr bool operator> (basic_string_view<charT, traits> x,
|
| 40 |
+
basic_string_view<charT, traits> y) noexcept;
|
| 41 |
+
template<class charT, class traits>
|
| 42 |
+
constexpr bool operator<=(basic_string_view<charT, traits> x,
|
| 43 |
+
basic_string_view<charT, traits> y) noexcept;
|
| 44 |
+
template<class charT, class traits>
|
| 45 |
+
constexpr bool operator>=(basic_string_view<charT, traits> x,
|
| 46 |
+
basic_string_view<charT, traits> y) noexcept;
|
| 47 |
+
// see [string.view.comparison], sufficient additional overloads of comparison functions
|
| 48 |
+
|
| 49 |
+
// [string.view.io], inserters and extractors
|
| 50 |
+
template<class charT, class traits>
|
| 51 |
+
basic_ostream<charT, traits>&
|
| 52 |
+
operator<<(basic_ostream<charT, traits>& os,
|
| 53 |
+
basic_string_view<charT, traits> str);
|
| 54 |
+
|
| 55 |
+
// basic_string_view typedef names
|
| 56 |
+
using string_view = basic_string_view<char>;
|
| 57 |
+
using u16string_view = basic_string_view<char16_t>;
|
| 58 |
+
using u32string_view = basic_string_view<char32_t>;
|
| 59 |
+
using wstring_view = basic_string_view<wchar_t>;
|
| 60 |
+
|
| 61 |
+
// [string.view.hash], hash support
|
| 62 |
+
template<class T> struct hash;
|
| 63 |
+
template<> struct hash<string_view>;
|
| 64 |
+
template<> struct hash<u16string_view>;
|
| 65 |
+
template<> struct hash<u32string_view>;
|
| 66 |
+
template<> struct hash<wstring_view>;
|
| 67 |
+
|
| 68 |
+
inline namespace literals {
|
| 69 |
+
inline namespace string_view_literals {
|
| 70 |
+
// [string.view.literals], suffix for basic_string_view literals
|
| 71 |
+
constexpr string_view operator""sv(const char* str, size_t len) noexcept;
|
| 72 |
+
constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept;
|
| 73 |
+
constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept;
|
| 74 |
+
constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
The function templates defined in [[utility.swap]] and
|
| 81 |
+
[[iterator.range]] are available when `<string_view>` is included.
|
| 82 |
+
|
| 83 |
+
### Class template `basic_string_view` <a id="string.view.template">[[string.view.template]]</a>
|
| 84 |
+
|
| 85 |
+
``` cpp
|
| 86 |
+
template<class charT, class traits = char_traits<charT>>
|
| 87 |
+
class basic_string_view {
|
| 88 |
+
public:
|
| 89 |
+
// types
|
| 90 |
+
using traits_type = traits;
|
| 91 |
+
using value_type = charT;
|
| 92 |
+
using pointer = value_type*;
|
| 93 |
+
using const_pointer = const value_type*;
|
| 94 |
+
using reference = value_type&;
|
| 95 |
+
using const_reference = const value_type&;
|
| 96 |
+
using const_iterator = implementation-defined // type of basic_string_view::const_iterator; // see [string.view.iterators]
|
| 97 |
+
using iterator = const_iterator;\footnote{Because basic_string_view refers to a constant sequence, iterator and const_iterator are the same type.}
|
| 98 |
+
using const_reverse_iterator = reverse_iterator<const_iterator>;
|
| 99 |
+
using reverse_iterator = const_reverse_iterator;
|
| 100 |
+
using size_type = size_t;
|
| 101 |
+
using difference_type = ptrdiff_t;
|
| 102 |
+
static constexpr size_type npos = size_type(-1);
|
| 103 |
+
|
| 104 |
+
// [string.view.cons], construction and assignment
|
| 105 |
+
constexpr basic_string_view() noexcept;
|
| 106 |
+
constexpr basic_string_view(const basic_string_view&) noexcept = default;
|
| 107 |
+
constexpr basic_string_view& operator=(const basic_string_view&) noexcept = default;
|
| 108 |
+
constexpr basic_string_view(const charT* str);
|
| 109 |
+
constexpr basic_string_view(const charT* str, size_type len);
|
| 110 |
+
|
| 111 |
+
// [string.view.iterators], iterator support
|
| 112 |
+
constexpr const_iterator begin() const noexcept;
|
| 113 |
+
constexpr const_iterator end() const noexcept;
|
| 114 |
+
constexpr const_iterator cbegin() const noexcept;
|
| 115 |
+
constexpr const_iterator cend() const noexcept;
|
| 116 |
+
constexpr const_reverse_iterator rbegin() const noexcept;
|
| 117 |
+
constexpr const_reverse_iterator rend() const noexcept;
|
| 118 |
+
constexpr const_reverse_iterator crbegin() const noexcept;
|
| 119 |
+
constexpr const_reverse_iterator crend() const noexcept;
|
| 120 |
+
|
| 121 |
+
// [string.view.capacity], capacity
|
| 122 |
+
constexpr size_type size() const noexcept;
|
| 123 |
+
constexpr size_type length() const noexcept;
|
| 124 |
+
constexpr size_type max_size() const noexcept;
|
| 125 |
+
constexpr bool empty() const noexcept;
|
| 126 |
+
|
| 127 |
+
// [string.view.access], element access
|
| 128 |
+
constexpr const_reference operator[](size_type pos) const;
|
| 129 |
+
constexpr const_reference at(size_type pos) const;
|
| 130 |
+
constexpr const_reference front() const;
|
| 131 |
+
constexpr const_reference back() const;
|
| 132 |
+
constexpr const_pointer data() const noexcept;
|
| 133 |
+
|
| 134 |
+
// [string.view.modifiers], modifiers
|
| 135 |
+
constexpr void remove_prefix(size_type n);
|
| 136 |
+
constexpr void remove_suffix(size_type n);
|
| 137 |
+
constexpr void swap(basic_string_view& s) noexcept;
|
| 138 |
+
|
| 139 |
+
// [string.view.ops], string operations
|
| 140 |
+
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
| 141 |
+
|
| 142 |
+
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
|
| 143 |
+
constexpr int compare(basic_string_view s) const noexcept;
|
| 144 |
+
constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
|
| 145 |
+
constexpr int compare(size_type pos1, size_type n1, basic_string_view s,
|
| 146 |
+
size_type pos2, size_type n2) const;
|
| 147 |
+
constexpr int compare(const charT* s) const;
|
| 148 |
+
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
|
| 149 |
+
constexpr int compare(size_type pos1, size_type n1, const charT* s,
|
| 150 |
+
size_type n2) const;
|
| 151 |
+
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
|
| 152 |
+
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
|
| 153 |
+
constexpr size_type find(const charT* s, size_type pos, size_type n) const;
|
| 154 |
+
constexpr size_type find(const charT* s, size_type pos = 0) const;
|
| 155 |
+
constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
|
| 156 |
+
constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
|
| 157 |
+
constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
|
| 158 |
+
constexpr size_type rfind(const charT* s, size_type pos = npos) const;
|
| 159 |
+
constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
|
| 160 |
+
constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
|
| 161 |
+
constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
|
| 162 |
+
constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
|
| 163 |
+
constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
|
| 164 |
+
constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
|
| 165 |
+
constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
|
| 166 |
+
constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
|
| 167 |
+
constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
|
| 168 |
+
constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
|
| 169 |
+
constexpr size_type find_first_not_of(const charT* s, size_type pos,
|
| 170 |
+
size_type n) const;
|
| 171 |
+
constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
|
| 172 |
+
constexpr size_type find_last_not_of(basic_string_view s,
|
| 173 |
+
size_type pos = npos) const noexcept;
|
| 174 |
+
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
|
| 175 |
+
constexpr size_type find_last_not_of(const charT* s, size_type pos,
|
| 176 |
+
size_type n) const;
|
| 177 |
+
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
|
| 178 |
+
|
| 179 |
+
private:
|
| 180 |
+
const_pointer data_; // exposition only
|
| 181 |
+
size_type size_; // exposition only
|
| 182 |
+
};
|
| 183 |
+
```
|
| 184 |
+
|
| 185 |
+
In every specialization `basic_string_view<charT, traits>`, the type
|
| 186 |
+
`traits` shall satisfy the character traits requirements (
|
| 187 |
+
[[char.traits]]), and the type `traits::char_type` shall name the same
|
| 188 |
+
type as `charT`.
|
| 189 |
+
|
| 190 |
+
#### Construction and assignment <a id="string.view.cons">[[string.view.cons]]</a>
|
| 191 |
+
|
| 192 |
+
``` cpp
|
| 193 |
+
constexpr basic_string_view() noexcept;
|
| 194 |
+
```
|
| 195 |
+
|
| 196 |
+
*Effects:* Constructs an empty `basic_string_view`.
|
| 197 |
+
|
| 198 |
+
*Postconditions:* `size_ == 0` and `data_ == nullptr`.
|
| 199 |
+
|
| 200 |
+
``` cpp
|
| 201 |
+
constexpr basic_string_view(const charT* str);
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
*Requires:* \[`str`, `str + traits::length(str)`) is a valid range.
|
| 205 |
+
|
| 206 |
+
*Effects:* Constructs a `basic_string_view`, with the postconditions in
|
| 207 |
+
Table [[tab:string.view.ctr.2]].
|
| 208 |
+
|
| 209 |
+
*Complexity:* 𝑂(`traits::length(str)`).
|
| 210 |
+
|
| 211 |
+
``` cpp
|
| 212 |
+
constexpr basic_string_view(const charT* str, size_type len);
|
| 213 |
+
```
|
| 214 |
+
|
| 215 |
+
*Requires:* \[`str`, `str + len`) is a valid range.
|
| 216 |
+
|
| 217 |
+
*Effects:* Constructs a `basic_string_view`, with the postconditions in
|
| 218 |
+
Table [[tab:string.view.ctr.3]].
|
| 219 |
+
|
| 220 |
+
#### Iterator support <a id="string.view.iterators">[[string.view.iterators]]</a>
|
| 221 |
+
|
| 222 |
+
``` cpp
|
| 223 |
+
using const_iterator = implementation-defined // type of basic_string_view::const_iterator;
|
| 224 |
+
```
|
| 225 |
+
|
| 226 |
+
A type that meets the requirements of a constant random access
|
| 227 |
+
iterator ([[random.access.iterators]]) and of a contiguous
|
| 228 |
+
iterator ([[iterator.requirements.general]]) whose `value_type` is the
|
| 229 |
+
template parameter `charT`.
|
| 230 |
+
|
| 231 |
+
For a `basic_string_view str`, any operation that invalidates a pointer
|
| 232 |
+
in the range \[`str.data()`, `str.data() + str.size()`) invalidates
|
| 233 |
+
pointers, iterators, and references returned from `str`’s methods.
|
| 234 |
+
|
| 235 |
+
All requirements on container iterators ([[container.requirements]])
|
| 236 |
+
apply to `basic_string_view::const_iterator` as well.
|
| 237 |
+
|
| 238 |
+
``` cpp
|
| 239 |
+
constexpr const_iterator begin() const noexcept;
|
| 240 |
+
constexpr const_iterator cbegin() const noexcept;
|
| 241 |
+
```
|
| 242 |
+
|
| 243 |
+
*Returns:* An iterator such that
|
| 244 |
+
|
| 245 |
+
- if `!empty()`, `&*begin() == data_`,
|
| 246 |
+
- otherwise, an unspecified value such that \[`begin()`, `end()`) is a
|
| 247 |
+
valid range.
|
| 248 |
+
|
| 249 |
+
``` cpp
|
| 250 |
+
constexpr const_iterator end() const noexcept;
|
| 251 |
+
constexpr const_iterator cend() const noexcept;
|
| 252 |
+
```
|
| 253 |
+
|
| 254 |
+
*Returns:* `begin() + size()`.
|
| 255 |
+
|
| 256 |
+
``` cpp
|
| 257 |
+
constexpr const_reverse_iterator rbegin() const noexcept;
|
| 258 |
+
constexpr const_reverse_iterator crbegin() const noexcept;
|
| 259 |
+
```
|
| 260 |
+
|
| 261 |
+
*Returns:* `const_reverse_iterator(end())`.
|
| 262 |
+
|
| 263 |
+
``` cpp
|
| 264 |
+
constexpr const_reverse_iterator rend() const noexcept;
|
| 265 |
+
constexpr const_reverse_iterator crend() const noexcept;
|
| 266 |
+
```
|
| 267 |
+
|
| 268 |
+
*Returns:* `const_reverse_iterator(begin())`.
|
| 269 |
+
|
| 270 |
+
#### Capacity <a id="string.view.capacity">[[string.view.capacity]]</a>
|
| 271 |
+
|
| 272 |
+
``` cpp
|
| 273 |
+
constexpr size_type size() const noexcept;
|
| 274 |
+
```
|
| 275 |
+
|
| 276 |
+
*Returns:* `size_`.
|
| 277 |
+
|
| 278 |
+
``` cpp
|
| 279 |
+
constexpr size_type length() const noexcept;
|
| 280 |
+
```
|
| 281 |
+
|
| 282 |
+
*Returns:* `size_`.
|
| 283 |
+
|
| 284 |
+
``` cpp
|
| 285 |
+
constexpr size_type max_size() const noexcept;
|
| 286 |
+
```
|
| 287 |
+
|
| 288 |
+
*Returns:* The largest possible number of char-like objects that can be
|
| 289 |
+
referred to by a `basic_string_view`.
|
| 290 |
+
|
| 291 |
+
``` cpp
|
| 292 |
+
constexpr bool empty() const noexcept;
|
| 293 |
+
```
|
| 294 |
+
|
| 295 |
+
*Returns:* `size_ == 0`.
|
| 296 |
+
|
| 297 |
+
#### Element access <a id="string.view.access">[[string.view.access]]</a>
|
| 298 |
+
|
| 299 |
+
``` cpp
|
| 300 |
+
constexpr const_reference operator[](size_type pos) const;
|
| 301 |
+
```
|
| 302 |
+
|
| 303 |
+
*Requires:* `pos < size()`.
|
| 304 |
+
|
| 305 |
+
*Returns:* `data_[pos]`.
|
| 306 |
+
|
| 307 |
+
*Throws:* Nothing.
|
| 308 |
+
|
| 309 |
+
[*Note 1*: Unlike `basic_string::operator[]`,
|
| 310 |
+
`basic_string_view::operator[](size())` has undefined behavior instead
|
| 311 |
+
of returning `charT()`. — *end note*]
|
| 312 |
+
|
| 313 |
+
``` cpp
|
| 314 |
+
constexpr const_reference at(size_type pos) const;
|
| 315 |
+
```
|
| 316 |
+
|
| 317 |
+
*Throws:* `out_of_range` if `pos >= size()`.
|
| 318 |
+
|
| 319 |
+
*Returns:* `data_[pos]`.
|
| 320 |
+
|
| 321 |
+
``` cpp
|
| 322 |
+
constexpr const_reference front() const;
|
| 323 |
+
```
|
| 324 |
+
|
| 325 |
+
*Requires:* `!empty()`.
|
| 326 |
+
|
| 327 |
+
*Returns:* `data_[0]`.
|
| 328 |
+
|
| 329 |
+
*Throws:* Nothing.
|
| 330 |
+
|
| 331 |
+
``` cpp
|
| 332 |
+
constexpr const_reference back() const;
|
| 333 |
+
```
|
| 334 |
+
|
| 335 |
+
*Requires:* `!empty()`.
|
| 336 |
+
|
| 337 |
+
*Returns:* `data_[size() - 1]`.
|
| 338 |
+
|
| 339 |
+
*Throws:* Nothing.
|
| 340 |
+
|
| 341 |
+
``` cpp
|
| 342 |
+
constexpr const_pointer data() const noexcept;
|
| 343 |
+
```
|
| 344 |
+
|
| 345 |
+
*Returns:* `data_`.
|
| 346 |
+
|
| 347 |
+
[*Note 2*: Unlike `basic_string::data()` and string literals, `data()`
|
| 348 |
+
may return a pointer to a buffer that is not null-terminated. Therefore
|
| 349 |
+
it is typically a mistake to pass `data()` to a function that takes just
|
| 350 |
+
a `const charT*` and expects a null-terminated string. — *end note*]
|
| 351 |
+
|
| 352 |
+
#### Modifiers <a id="string.view.modifiers">[[string.view.modifiers]]</a>
|
| 353 |
+
|
| 354 |
+
``` cpp
|
| 355 |
+
constexpr void remove_prefix(size_type n);
|
| 356 |
+
```
|
| 357 |
+
|
| 358 |
+
*Requires:* `n <= size()`.
|
| 359 |
+
|
| 360 |
+
*Effects:* Equivalent to: `data_ += n; size_ -= n;`
|
| 361 |
+
|
| 362 |
+
``` cpp
|
| 363 |
+
constexpr void remove_suffix(size_type n);
|
| 364 |
+
```
|
| 365 |
+
|
| 366 |
+
*Requires:* `n <= size()`.
|
| 367 |
+
|
| 368 |
+
*Effects:* Equivalent to: `size_ -= n;`
|
| 369 |
+
|
| 370 |
+
``` cpp
|
| 371 |
+
constexpr void swap(basic_string_view& s) noexcept;
|
| 372 |
+
```
|
| 373 |
+
|
| 374 |
+
*Effects:* Exchanges the values of `*this` and `s`.
|
| 375 |
+
|
| 376 |
+
#### String operations <a id="string.view.ops">[[string.view.ops]]</a>
|
| 377 |
+
|
| 378 |
+
``` cpp
|
| 379 |
+
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
| 380 |
+
```
|
| 381 |
+
|
| 382 |
+
Let `rlen` be the smaller of `n` and `size() - pos`.
|
| 383 |
+
|
| 384 |
+
*Throws:* `out_of_range` if `pos > size()`.
|
| 385 |
+
|
| 386 |
+
*Requires:* \[`s`, `s + rlen`) is a valid range.
|
| 387 |
+
|
| 388 |
+
*Effects:* Equivalent to `traits::copy(s, data() + pos, rlen)`.
|
| 389 |
+
|
| 390 |
+
*Returns:* `rlen`.
|
| 391 |
+
|
| 392 |
+
*Complexity:* 𝑂(`rlen`).
|
| 393 |
+
|
| 394 |
+
``` cpp
|
| 395 |
+
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
|
| 396 |
+
```
|
| 397 |
+
|
| 398 |
+
Let `rlen` be the smaller of `n` and `size() - pos`.
|
| 399 |
+
|
| 400 |
+
*Throws:* `out_of_range` if `pos > size()`.
|
| 401 |
+
|
| 402 |
+
*Effects:* Determines `rlen`, the effective length of the string to
|
| 403 |
+
reference.
|
| 404 |
+
|
| 405 |
+
*Returns:* `basic_string_view(data() + pos, rlen)`.
|
| 406 |
+
|
| 407 |
+
``` cpp
|
| 408 |
+
constexpr int compare(basic_string_view str) const noexcept;
|
| 409 |
+
```
|
| 410 |
+
|
| 411 |
+
Let `rlen` be the smaller of `size()` and `str.size()`.
|
| 412 |
+
|
| 413 |
+
*Effects:* Determines `rlen`, the effective length of the strings to
|
| 414 |
+
compare. The function then compares the two strings by calling
|
| 415 |
+
`traits::compare(data(), str.data(), rlen)`.
|
| 416 |
+
|
| 417 |
+
*Complexity:* 𝑂(`rlen`).
|
| 418 |
+
|
| 419 |
+
*Returns:* The nonzero result if the result of the comparison is
|
| 420 |
+
nonzero. Otherwise, returns a value as indicated in
|
| 421 |
+
Table [[tab:string.view.compare]].
|
| 422 |
+
|
| 423 |
+
**Table: `compare()` results** <a id="tab:string.view.compare">[tab:string.view.compare]</a>
|
| 424 |
+
|
| 425 |
+
| Condition | Return Value |
|
| 426 |
+
| ---------------------- | ------------ |
|
| 427 |
+
| `size() < str.size()` | `< 0` |
|
| 428 |
+
| `size() == str.size()` | ` 0` |
|
| 429 |
+
| `size() > str.size()` | `> 0` |
|
| 430 |
+
|
| 431 |
+
``` cpp
|
| 432 |
+
constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
|
| 433 |
+
```
|
| 434 |
+
|
| 435 |
+
*Effects:* Equivalent to: `return substr(pos1, n1).compare(str);`
|
| 436 |
+
|
| 437 |
+
``` cpp
|
| 438 |
+
constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
|
| 439 |
+
size_type pos2, size_type n2) const;
|
| 440 |
+
```
|
| 441 |
+
|
| 442 |
+
*Effects:* Equivalent to:
|
| 443 |
+
`return substr(pos1, n1).compare(str.substr(pos2, n2));`
|
| 444 |
+
|
| 445 |
+
``` cpp
|
| 446 |
+
constexpr int compare(const charT* s) const;
|
| 447 |
+
```
|
| 448 |
+
|
| 449 |
+
*Effects:* Equivalent to: `return compare(basic_string_view(s));`
|
| 450 |
+
|
| 451 |
+
``` cpp
|
| 452 |
+
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
|
| 453 |
+
```
|
| 454 |
+
|
| 455 |
+
*Effects:* Equivalent to:
|
| 456 |
+
`return substr(pos1, n1).compare(basic_string_view(s));`
|
| 457 |
+
|
| 458 |
+
``` cpp
|
| 459 |
+
constexpr int compare(size_type pos1, size_type n1,
|
| 460 |
+
const charT* s, size_type n2) const;
|
| 461 |
+
```
|
| 462 |
+
|
| 463 |
+
*Effects:* Equivalent to:
|
| 464 |
+
`return substr(pos1, n1).compare(basic_string_view(s, n2));`
|
| 465 |
+
|
| 466 |
+
#### Searching <a id="string.view.find">[[string.view.find]]</a>
|
| 467 |
+
|
| 468 |
+
This section specifies the `basic_string_view` member functions named
|
| 469 |
+
`find`, `rfind`, `find_first_of`, `find_last_of`, `find_first_not_of`,
|
| 470 |
+
and `find_last_not_of`.
|
| 471 |
+
|
| 472 |
+
Member functions in this section have complexity
|
| 473 |
+
𝑂(`size() * str.size()`) at worst, although implementations are
|
| 474 |
+
encouraged to do better.
|
| 475 |
+
|
| 476 |
+
Each member function of the form
|
| 477 |
+
|
| 478 |
+
``` cpp
|
| 479 |
+
constexpr return-type F(const charT* s, size_type pos);
|
| 480 |
+
```
|
| 481 |
+
|
| 482 |
+
is equivalent to `return F(basic_string_view(s), pos);`
|
| 483 |
+
|
| 484 |
+
Each member function of the form
|
| 485 |
+
|
| 486 |
+
``` cpp
|
| 487 |
+
constexpr return-type F(const charT* s, size_type pos, size_type n);
|
| 488 |
+
```
|
| 489 |
+
|
| 490 |
+
is equivalent to `return F(basic_string_view(s, n), pos);`
|
| 491 |
+
|
| 492 |
+
Each member function of the form
|
| 493 |
+
|
| 494 |
+
``` cpp
|
| 495 |
+
constexpr return-type F(charT c, size_type pos);
|
| 496 |
+
```
|
| 497 |
+
|
| 498 |
+
is equivalent to `return F(basic_string_view(&c, 1), pos);`
|
| 499 |
+
|
| 500 |
+
``` cpp
|
| 501 |
+
constexpr size_type find(basic_string_view str, size_type pos = 0) const noexcept;
|
| 502 |
+
```
|
| 503 |
+
|
| 504 |
+
Let `xpos` be the lowest position, if possible, such that the following
|
| 505 |
+
conditions hold:
|
| 506 |
+
|
| 507 |
+
- `pos <= xpos`
|
| 508 |
+
- `xpos + str.size() <= size()`
|
| 509 |
+
- `traits::eq(at(xpos + I), str.at(I))` for all elements `I` of the
|
| 510 |
+
string referenced by `str`.
|
| 511 |
+
|
| 512 |
+
*Effects:* Determines `xpos`.
|
| 513 |
+
|
| 514 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 515 |
+
Otherwise, returns `npos`.
|
| 516 |
+
|
| 517 |
+
``` cpp
|
| 518 |
+
constexpr size_type rfind(basic_string_view str, size_type pos = npos) const noexcept;
|
| 519 |
+
```
|
| 520 |
+
|
| 521 |
+
Let `xpos` be the highest position, if possible, such that the following
|
| 522 |
+
conditions hold:
|
| 523 |
+
|
| 524 |
+
- `xpos <= pos`
|
| 525 |
+
- `xpos + str.size() <= size()`
|
| 526 |
+
- `traits::eq(at(xpos + I), str.at(I))` for all elements `I` of the
|
| 527 |
+
string referenced by `str`.
|
| 528 |
+
|
| 529 |
+
*Effects:* Determines `xpos`.
|
| 530 |
+
|
| 531 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 532 |
+
Otherwise, returns `npos`.
|
| 533 |
+
|
| 534 |
+
``` cpp
|
| 535 |
+
constexpr size_type find_first_of(basic_string_view str, size_type pos = 0) const noexcept;
|
| 536 |
+
```
|
| 537 |
+
|
| 538 |
+
Let `xpos` be the lowest position, if possible, such that the following
|
| 539 |
+
conditions hold:
|
| 540 |
+
|
| 541 |
+
- `pos <= xpos`
|
| 542 |
+
- `xpos < size()`
|
| 543 |
+
- `traits::eq(at(xpos), str.at(I))` for some element `I` of the string
|
| 544 |
+
referenced by `str`.
|
| 545 |
+
|
| 546 |
+
*Effects:* Determines `xpos`.
|
| 547 |
+
|
| 548 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 549 |
+
Otherwise, returns `npos`.
|
| 550 |
+
|
| 551 |
+
``` cpp
|
| 552 |
+
constexpr size_type find_last_of(basic_string_view str, size_type pos = npos) const noexcept;
|
| 553 |
+
```
|
| 554 |
+
|
| 555 |
+
Let `xpos` be the highest position, if possible, such that the following
|
| 556 |
+
conditions hold:
|
| 557 |
+
|
| 558 |
+
- `xpos <= pos`
|
| 559 |
+
- `xpos < size()`
|
| 560 |
+
- `traits::eq(at(xpos), str.at(I))` for some element `I` of the string
|
| 561 |
+
referenced by `str`.
|
| 562 |
+
|
| 563 |
+
*Effects:* Determines `xpos`.
|
| 564 |
+
|
| 565 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 566 |
+
Otherwise, returns `npos`.
|
| 567 |
+
|
| 568 |
+
``` cpp
|
| 569 |
+
constexpr size_type find_first_not_of(basic_string_view str, size_type pos = 0) const noexcept;
|
| 570 |
+
```
|
| 571 |
+
|
| 572 |
+
Let `xpos` be the lowest position, if possible, such that the following
|
| 573 |
+
conditions hold:
|
| 574 |
+
|
| 575 |
+
- `pos <= xpos`
|
| 576 |
+
- `xpos < size()`
|
| 577 |
+
- `traits::eq(at(xpos), str.at(I))` for no element `I` of the string
|
| 578 |
+
referenced by `str`.
|
| 579 |
+
|
| 580 |
+
*Effects:* Determines `xpos`.
|
| 581 |
+
|
| 582 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 583 |
+
Otherwise, returns `npos`.
|
| 584 |
+
|
| 585 |
+
``` cpp
|
| 586 |
+
constexpr size_type find_last_not_of(basic_string_view str, size_type pos = npos) const noexcept;
|
| 587 |
+
```
|
| 588 |
+
|
| 589 |
+
Let `xpos` be the highest position, if possible, such that the following
|
| 590 |
+
conditions hold:
|
| 591 |
+
|
| 592 |
+
- `xpos <= pos`
|
| 593 |
+
- `xpos < size()`
|
| 594 |
+
- `traits::eq(at(xpos), str.at(I))` for no element `I` of the string
|
| 595 |
+
referenced by `str`.
|
| 596 |
+
|
| 597 |
+
*Effects:* Determines `xpos`.
|
| 598 |
+
|
| 599 |
+
*Returns:* `xpos` if the function can determine such a value for `xpos`.
|
| 600 |
+
Otherwise, returns `npos`.
|
| 601 |
+
|
| 602 |
+
### Non-member comparison functions <a id="string.view.comparison">[[string.view.comparison]]</a>
|
| 603 |
+
|
| 604 |
+
Let `S` be `basic_string_view<charT, traits>`, and `sv` be an instance
|
| 605 |
+
of `S`. Implementations shall provide sufficient additional overloads
|
| 606 |
+
marked `constexpr` and `noexcept` so that an object `t` with an implicit
|
| 607 |
+
conversion to `S` can be compared according to Table
|
| 608 |
+
[[tab:string.view.comparison.overloads]].
|
| 609 |
+
|
| 610 |
+
**Table: Additional `basic_string_view` comparison overloads** <a id="tab:string.view.comparison.overloads">[tab:string.view.comparison.overloads]</a>
|
| 611 |
+
|
| 612 |
+
| Expression | Equivalent to |
|
| 613 |
+
| ---------- | ------------- |
|
| 614 |
+
| `t == sv` | `S(t) == sv` |
|
| 615 |
+
| `sv == t` | `sv == S(t)` |
|
| 616 |
+
| `t != sv` | `S(t) != sv` |
|
| 617 |
+
| `sv != t` | `sv != S(t)` |
|
| 618 |
+
| `t < sv` | `S(t) < sv` |
|
| 619 |
+
| `sv < t` | `sv < S(t)` |
|
| 620 |
+
| `t > sv` | `S(t) > sv` |
|
| 621 |
+
| `sv > t` | `sv > S(t)` |
|
| 622 |
+
| `t <= sv` | `S(t) <= sv` |
|
| 623 |
+
| `sv <= t` | `sv <= S(t)` |
|
| 624 |
+
| `t >= sv` | `S(t) >= sv` |
|
| 625 |
+
| `sv >= t` | `sv >= S(t)` |
|
| 626 |
+
|
| 627 |
+
|
| 628 |
+
[*Example 1*:
|
| 629 |
+
|
| 630 |
+
A sample conforming implementation for `operator==` would be:
|
| 631 |
+
|
| 632 |
+
``` cpp
|
| 633 |
+
template<class T> using __identity = decay_t<T>;
|
| 634 |
+
template<class charT, class traits>
|
| 635 |
+
constexpr bool operator==(basic_string_view<charT, traits> lhs,
|
| 636 |
+
basic_string_view<charT, traits> rhs) noexcept {
|
| 637 |
+
return lhs.compare(rhs) == 0;
|
| 638 |
+
}
|
| 639 |
+
template<class charT, class traits>
|
| 640 |
+
constexpr bool operator==(basic_string_view<charT, traits> lhs,
|
| 641 |
+
__identity<basic_string_view<charT, traits>> rhs) noexcept {
|
| 642 |
+
return lhs.compare(rhs) == 0;
|
| 643 |
+
}
|
| 644 |
+
template<class charT, class traits>
|
| 645 |
+
constexpr bool operator==(__identity<basic_string_view<charT, traits>> lhs,
|
| 646 |
+
basic_string_view<charT, traits> rhs) noexcept {
|
| 647 |
+
return lhs.compare(rhs) == 0;
|
| 648 |
+
}
|
| 649 |
+
```
|
| 650 |
+
|
| 651 |
+
— *end example*]
|
| 652 |
+
|
| 653 |
+
``` cpp
|
| 654 |
+
template<class charT, class traits>
|
| 655 |
+
constexpr bool operator==(basic_string_view<charT, traits> lhs,
|
| 656 |
+
basic_string_view<charT, traits> rhs) noexcept;
|
| 657 |
+
```
|
| 658 |
+
|
| 659 |
+
*Returns:* `lhs.compare(rhs) == 0`.
|
| 660 |
+
|
| 661 |
+
``` cpp
|
| 662 |
+
template<class charT, class traits>
|
| 663 |
+
constexpr bool operator!=(basic_string_view<charT, traits> lhs,
|
| 664 |
+
basic_string_view<charT, traits> rhs) noexcept;
|
| 665 |
+
```
|
| 666 |
+
|
| 667 |
+
*Returns:* `lhs.compare(rhs) != 0`.
|
| 668 |
+
|
| 669 |
+
``` cpp
|
| 670 |
+
template<class charT, class traits>
|
| 671 |
+
constexpr bool operator< (basic_string_view<charT, traits> lhs,
|
| 672 |
+
basic_string_view<charT, traits> rhs) noexcept;
|
| 673 |
+
```
|
| 674 |
+
|
| 675 |
+
*Returns:* `lhs.compare(rhs) < 0`.
|
| 676 |
+
|
| 677 |
+
``` cpp
|
| 678 |
+
template<class charT, class traits>
|
| 679 |
+
constexpr bool operator> (basic_string_view<charT, traits> lhs,
|
| 680 |
+
basic_string_view<charT, traits> rhs) noexcept;
|
| 681 |
+
```
|
| 682 |
+
|
| 683 |
+
*Returns:* `lhs.compare(rhs) > 0`.
|
| 684 |
+
|
| 685 |
+
``` cpp
|
| 686 |
+
template<class charT, class traits>
|
| 687 |
+
constexpr bool operator<=(basic_string_view<charT, traits> lhs,
|
| 688 |
+
basic_string_view<charT, traits> rhs) noexcept;
|
| 689 |
+
```
|
| 690 |
+
|
| 691 |
+
*Returns:* `lhs.compare(rhs) <= 0`.
|
| 692 |
+
|
| 693 |
+
``` cpp
|
| 694 |
+
template<class charT, class traits>
|
| 695 |
+
constexpr bool operator>=(basic_string_view<charT, traits> lhs,
|
| 696 |
+
basic_string_view<charT, traits> rhs) noexcept;
|
| 697 |
+
```
|
| 698 |
+
|
| 699 |
+
*Returns:* `lhs.compare(rhs) >= 0`.
|
| 700 |
+
|
| 701 |
+
### Inserters and extractors <a id="string.view.io">[[string.view.io]]</a>
|
| 702 |
+
|
| 703 |
+
``` cpp
|
| 704 |
+
template<class charT, class traits>
|
| 705 |
+
basic_ostream<charT, traits>&
|
| 706 |
+
operator<<(basic_ostream<charT, traits>& os,
|
| 707 |
+
basic_string_view<charT, traits> str);
|
| 708 |
+
```
|
| 709 |
+
|
| 710 |
+
*Effects:* Behaves as a formatted output
|
| 711 |
+
function ([[ostream.formatted.reqmts]]) of `os`. Forms a character
|
| 712 |
+
sequence `seq`, initially consisting of the elements defined by the
|
| 713 |
+
range \[`str.begin()`, `str.end()`). Determines padding for `seq` as
|
| 714 |
+
described in [[ostream.formatted.reqmts]]. Then inserts `seq` as if by
|
| 715 |
+
calling `os.rdbuf()->sputn(seq, n)`, where `n` is the larger of
|
| 716 |
+
`os.width()` and `str.size()`; then calls `os.width(0)`.
|
| 717 |
+
|
| 718 |
+
*Returns:* `os`
|
| 719 |
+
|
| 720 |
+
### Hash support <a id="string.view.hash">[[string.view.hash]]</a>
|
| 721 |
+
|
| 722 |
+
``` cpp
|
| 723 |
+
template<> struct hash<string_view>;
|
| 724 |
+
template<> struct hash<u16string_view>;
|
| 725 |
+
template<> struct hash<u32string_view>;
|
| 726 |
+
template<> struct hash<wstring_view>;
|
| 727 |
+
```
|
| 728 |
+
|
| 729 |
+
The specialization is enabled ([[unord.hash]]).
|
| 730 |
+
|
| 731 |
+
[*Note 1*: The hash value of a string view object is equal to the hash
|
| 732 |
+
value of the corresponding string object
|
| 733 |
+
([[basic.string.hash]]). — *end note*]
|
| 734 |
+
|
| 735 |
+
### Suffix for `basic_string_view` literals <a id="string.view.literals">[[string.view.literals]]</a>
|
| 736 |
+
|
| 737 |
+
``` cpp
|
| 738 |
+
constexpr string_view operator""sv(const char* str, size_t len) noexcept;
|
| 739 |
+
```
|
| 740 |
+
|
| 741 |
+
*Returns:* `string_view{str, len}`.
|
| 742 |
+
|
| 743 |
+
``` cpp
|
| 744 |
+
constexpr u16string_view operator""sv(const char16_t* str, size_t len) noexcept;
|
| 745 |
+
```
|
| 746 |
+
|
| 747 |
+
*Returns:* `u16string_view{str, len}`.
|
| 748 |
+
|
| 749 |
+
``` cpp
|
| 750 |
+
constexpr u32string_view operator""sv(const char32_t* str, size_t len) noexcept;
|
| 751 |
+
```
|
| 752 |
+
|
| 753 |
+
*Returns:* `u32string_view{str, len}`.
|
| 754 |
+
|
| 755 |
+
``` cpp
|
| 756 |
+
constexpr wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
|
| 757 |
+
```
|
| 758 |
+
|
| 759 |
+
*Returns:* `wstring_view{str, len}`.
|
| 760 |
+
|