]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/include/std/string_view
P0482R5 char8_t: Standard library support
[thirdparty/gcc.git] / libstdc++-v3 / include / std / string_view
1 // Components for manipulating non-owning sequences of characters -*- C++ -*-
2
3 // Copyright (C) 2013-2019 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24
25 /** @file string_view
26 * This is a Standard C++ Library header.
27 */
28
29 //
30 // N3762 basic_string_view library
31 //
32
33 #ifndef _GLIBCXX_STRING_VIEW
34 #define _GLIBCXX_STRING_VIEW 1
35
36 #pragma GCC system_header
37
38 #if __cplusplus >= 201703L
39
40 #include <limits>
41 #include <iosfwd>
42 #include <bits/char_traits.h>
43 #include <bits/functional_hash.h>
44 #include <bits/range_access.h>
45
46 namespace std _GLIBCXX_VISIBILITY(default)
47 {
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
49
50 #define __cpp_lib_string_view 201603
51
52 /**
53 * @class basic_string_view <string_view>
54 * @brief A non-owning reference to a string.
55 *
56 * @ingroup strings
57 * @ingroup sequences
58 *
59 * @tparam _CharT Type of character
60 * @tparam _Traits Traits for character type, defaults to
61 * char_traits<_CharT>.
62 *
63 * A basic_string_view looks like this:
64 *
65 * @code
66 * _CharT* _M_str
67 * size_t _M_len
68 * @endcode
69 */
70 template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
71 class basic_string_view
72 {
73 public:
74
75 // types
76 using traits_type = _Traits;
77 using value_type = _CharT;
78 using pointer = const _CharT*;
79 using const_pointer = const _CharT*;
80 using reference = const _CharT&;
81 using const_reference = const _CharT&;
82 using const_iterator = const _CharT*;
83 using iterator = const_iterator;
84 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
85 using reverse_iterator = const_reverse_iterator;
86 using size_type = size_t;
87 using difference_type = ptrdiff_t;
88 static constexpr size_type npos = size_type(-1);
89
90 // [string.view.cons], construct/copy
91
92 constexpr
93 basic_string_view() noexcept
94 : _M_len{0}, _M_str{nullptr}
95 { }
96
97 constexpr basic_string_view(const basic_string_view&) noexcept = default;
98
99 __attribute__((__nonnull__)) constexpr
100 basic_string_view(const _CharT* __str) noexcept
101 : _M_len{traits_type::length(__str)},
102 _M_str{__str}
103 { }
104
105 constexpr
106 basic_string_view(const _CharT* __str, size_type __len) noexcept
107 : _M_len{__len}, _M_str{__str}
108 { }
109
110 constexpr basic_string_view&
111 operator=(const basic_string_view&) noexcept = default;
112
113 // [string.view.iterators], iterators
114
115 constexpr const_iterator
116 begin() const noexcept
117 { return this->_M_str; }
118
119 constexpr const_iterator
120 end() const noexcept
121 { return this->_M_str + this->_M_len; }
122
123 constexpr const_iterator
124 cbegin() const noexcept
125 { return this->_M_str; }
126
127 constexpr const_iterator
128 cend() const noexcept
129 { return this->_M_str + this->_M_len; }
130
131 constexpr const_reverse_iterator
132 rbegin() const noexcept
133 { return const_reverse_iterator(this->end()); }
134
135 constexpr const_reverse_iterator
136 rend() const noexcept
137 { return const_reverse_iterator(this->begin()); }
138
139 constexpr const_reverse_iterator
140 crbegin() const noexcept
141 { return const_reverse_iterator(this->end()); }
142
143 constexpr const_reverse_iterator
144 crend() const noexcept
145 { return const_reverse_iterator(this->begin()); }
146
147 // [string.view.capacity], capacity
148
149 constexpr size_type
150 size() const noexcept
151 { return this->_M_len; }
152
153 constexpr size_type
154 length() const noexcept
155 { return _M_len; }
156
157 constexpr size_type
158 max_size() const noexcept
159 {
160 return (npos - sizeof(size_type) - sizeof(void*))
161 / sizeof(value_type) / 4;
162 }
163
164 [[nodiscard]] constexpr bool
165 empty() const noexcept
166 { return this->_M_len == 0; }
167
168 // [string.view.access], element access
169
170 constexpr const _CharT&
171 operator[](size_type __pos) const noexcept
172 {
173 // TODO: Assert to restore in a way compatible with the constexpr.
174 // __glibcxx_assert(__pos < this->_M_len);
175 return *(this->_M_str + __pos);
176 }
177
178 constexpr const _CharT&
179 at(size_type __pos) const
180 {
181 if (__pos >= _M_len)
182 __throw_out_of_range_fmt(__N("basic_string_view::at: __pos "
183 "(which is %zu) >= this->size() "
184 "(which is %zu)"), __pos, this->size());
185 return *(this->_M_str + __pos);
186 }
187
188 constexpr const _CharT&
189 front() const noexcept
190 {
191 // TODO: Assert to restore in a way compatible with the constexpr.
192 // __glibcxx_assert(this->_M_len > 0);
193 return *this->_M_str;
194 }
195
196 constexpr const _CharT&
197 back() const noexcept
198 {
199 // TODO: Assert to restore in a way compatible with the constexpr.
200 // __glibcxx_assert(this->_M_len > 0);
201 return *(this->_M_str + this->_M_len - 1);
202 }
203
204 constexpr const _CharT*
205 data() const noexcept
206 { return this->_M_str; }
207
208 // [string.view.modifiers], modifiers:
209
210 constexpr void
211 remove_prefix(size_type __n) noexcept
212 {
213 __glibcxx_assert(this->_M_len >= __n);
214 this->_M_str += __n;
215 this->_M_len -= __n;
216 }
217
218 constexpr void
219 remove_suffix(size_type __n) noexcept
220 { this->_M_len -= __n; }
221
222 constexpr void
223 swap(basic_string_view& __sv) noexcept
224 {
225 auto __tmp = *this;
226 *this = __sv;
227 __sv = __tmp;
228 }
229
230 // [string.view.ops], string operations:
231
232 size_type
233 copy(_CharT* __str, size_type __n, size_type __pos = 0) const
234 {
235 __glibcxx_requires_string_len(__str, __n);
236 __pos = _M_check(__pos, "basic_string_view::copy");
237 const size_type __rlen = std::min(__n, _M_len - __pos);
238 // _GLIBCXX_RESOLVE_LIB_DEFECTS
239 // 2777. basic_string_view::copy should use char_traits::copy
240 traits_type::copy(__str, data() + __pos, __rlen);
241 return __rlen;
242 }
243
244 constexpr basic_string_view
245 substr(size_type __pos = 0, size_type __n = npos) const noexcept(false)
246 {
247 __pos = _M_check(__pos, "basic_string_view::substr");
248 const size_type __rlen = std::min(__n, _M_len - __pos);
249 return basic_string_view{_M_str + __pos, __rlen};
250 }
251
252 constexpr int
253 compare(basic_string_view __str) const noexcept
254 {
255 const size_type __rlen = std::min(this->_M_len, __str._M_len);
256 int __ret = traits_type::compare(this->_M_str, __str._M_str, __rlen);
257 if (__ret == 0)
258 __ret = _S_compare(this->_M_len, __str._M_len);
259 return __ret;
260 }
261
262 constexpr int
263 compare(size_type __pos1, size_type __n1, basic_string_view __str) const
264 { return this->substr(__pos1, __n1).compare(__str); }
265
266 constexpr int
267 compare(size_type __pos1, size_type __n1,
268 basic_string_view __str, size_type __pos2, size_type __n2) const
269 {
270 return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2));
271 }
272
273 __attribute__((__nonnull__)) constexpr int
274 compare(const _CharT* __str) const noexcept
275 { return this->compare(basic_string_view{__str}); }
276
277 __attribute__((__nonnull__)) constexpr int
278 compare(size_type __pos1, size_type __n1, const _CharT* __str) const
279 { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
280
281 constexpr int
282 compare(size_type __pos1, size_type __n1,
283 const _CharT* __str, size_type __n2) const noexcept(false)
284 {
285 return this->substr(__pos1, __n1)
286 .compare(basic_string_view(__str, __n2));
287 }
288
289 constexpr size_type
290 find(basic_string_view __str, size_type __pos = 0) const noexcept
291 { return this->find(__str._M_str, __pos, __str._M_len); }
292
293 constexpr size_type
294 find(_CharT __c, size_type __pos = 0) const noexcept;
295
296 constexpr size_type
297 find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
298
299 __attribute__((__nonnull__)) constexpr size_type
300 find(const _CharT* __str, size_type __pos = 0) const noexcept
301 { return this->find(__str, __pos, traits_type::length(__str)); }
302
303 constexpr size_type
304 rfind(basic_string_view __str, size_type __pos = npos) const noexcept
305 { return this->rfind(__str._M_str, __pos, __str._M_len); }
306
307 constexpr size_type
308 rfind(_CharT __c, size_type __pos = npos) const noexcept;
309
310 constexpr size_type
311 rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
312
313 __attribute__((__nonnull__)) constexpr size_type
314 rfind(const _CharT* __str, size_type __pos = npos) const noexcept
315 { return this->rfind(__str, __pos, traits_type::length(__str)); }
316
317 constexpr size_type
318 find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
319 { return this->find_first_of(__str._M_str, __pos, __str._M_len); }
320
321 constexpr size_type
322 find_first_of(_CharT __c, size_type __pos = 0) const noexcept
323 { return this->find(__c, __pos); }
324
325 constexpr size_type
326 find_first_of(const _CharT* __str, size_type __pos,
327 size_type __n) const noexcept;
328
329 __attribute__((__nonnull__)) constexpr size_type
330 find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
331 { return this->find_first_of(__str, __pos, traits_type::length(__str)); }
332
333 constexpr size_type
334 find_last_of(basic_string_view __str,
335 size_type __pos = npos) const noexcept
336 { return this->find_last_of(__str._M_str, __pos, __str._M_len); }
337
338 constexpr size_type
339 find_last_of(_CharT __c, size_type __pos=npos) const noexcept
340 { return this->rfind(__c, __pos); }
341
342 constexpr size_type
343 find_last_of(const _CharT* __str, size_type __pos,
344 size_type __n) const noexcept;
345
346 __attribute__((__nonnull__)) constexpr size_type
347 find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
348 { return this->find_last_of(__str, __pos, traits_type::length(__str)); }
349
350 constexpr size_type
351 find_first_not_of(basic_string_view __str,
352 size_type __pos = 0) const noexcept
353 { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
354
355 constexpr size_type
356 find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
357
358 constexpr size_type
359 find_first_not_of(const _CharT* __str,
360 size_type __pos, size_type __n) const noexcept;
361
362 __attribute__((__nonnull__)) constexpr size_type
363 find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
364 {
365 return this->find_first_not_of(__str, __pos,
366 traits_type::length(__str));
367 }
368
369 constexpr size_type
370 find_last_not_of(basic_string_view __str,
371 size_type __pos = npos) const noexcept
372 { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
373
374 constexpr size_type
375 find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
376
377 constexpr size_type
378 find_last_not_of(const _CharT* __str,
379 size_type __pos, size_type __n) const noexcept;
380
381 __attribute__((__nonnull__)) constexpr size_type
382 find_last_not_of(const _CharT* __str,
383 size_type __pos = npos) const noexcept
384 {
385 return this->find_last_not_of(__str, __pos,
386 traits_type::length(__str));
387 }
388
389 #if __cplusplus > 201703L
390 constexpr bool
391 starts_with(basic_string_view __x) const noexcept
392 { return this->substr(0, __x.size()) == __x; }
393
394 constexpr bool
395 starts_with(_CharT __x) const noexcept
396 { return !this->empty() && traits_type::eq(this->front(), __x); }
397
398 constexpr bool
399 starts_with(const _CharT* __x) const noexcept
400 { return this->starts_with(basic_string_view(__x)); }
401
402 constexpr bool
403 ends_with(basic_string_view __x) const noexcept
404 {
405 return this->size() >= __x.size()
406 && this->compare(this->size() - __x.size(), npos, __x) == 0;
407 }
408
409 constexpr bool
410 ends_with(_CharT __x) const noexcept
411 { return !this->empty() && traits_type::eq(this->back(), __x); }
412
413 constexpr bool
414 ends_with(const _CharT* __x) const noexcept
415 { return this->ends_with(basic_string_view(__x)); }
416 #endif // C++20
417
418 constexpr size_type
419 _M_check(size_type __pos, const char* __s) const noexcept(false)
420 {
421 if (__pos > this->size())
422 __throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > "
423 "this->size() (which is %zu)"),
424 __s, __pos, this->size());
425 return __pos;
426 }
427
428 // NB: _M_limit doesn't check for a bad __pos value.
429 constexpr size_type
430 _M_limit(size_type __pos, size_type __off) const noexcept
431 {
432 const bool __testoff = __off < this->size() - __pos;
433 return __testoff ? __off : this->size() - __pos;
434 }
435
436 private:
437
438 static constexpr int
439 _S_compare(size_type __n1, size_type __n2) noexcept
440 {
441 const difference_type __diff = __n1 - __n2;
442 if (__diff > std::numeric_limits<int>::max())
443 return std::numeric_limits<int>::max();
444 if (__diff < std::numeric_limits<int>::min())
445 return std::numeric_limits<int>::min();
446 return static_cast<int>(__diff);
447 }
448
449 size_t _M_len;
450 const _CharT* _M_str;
451 };
452
453 // [string.view.comparison], non-member basic_string_view comparison function
454
455 namespace __detail
456 {
457 // Identity transform to create a non-deduced context, so that only one
458 // argument participates in template argument deduction and the other
459 // argument gets implicitly converted to the deduced type. See n3766.html.
460 template<typename _Tp>
461 using __idt = common_type_t<_Tp>;
462 }
463
464 template<typename _CharT, typename _Traits>
465 constexpr bool
466 operator==(basic_string_view<_CharT, _Traits> __x,
467 basic_string_view<_CharT, _Traits> __y) noexcept
468 { return __x.size() == __y.size() && __x.compare(__y) == 0; }
469
470 template<typename _CharT, typename _Traits>
471 constexpr bool
472 operator==(basic_string_view<_CharT, _Traits> __x,
473 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
474 { return __x.size() == __y.size() && __x.compare(__y) == 0; }
475
476 template<typename _CharT, typename _Traits>
477 constexpr bool
478 operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
479 basic_string_view<_CharT, _Traits> __y) noexcept
480 { return __x.size() == __y.size() && __x.compare(__y) == 0; }
481
482 template<typename _CharT, typename _Traits>
483 constexpr bool
484 operator!=(basic_string_view<_CharT, _Traits> __x,
485 basic_string_view<_CharT, _Traits> __y) noexcept
486 { return !(__x == __y); }
487
488 template<typename _CharT, typename _Traits>
489 constexpr bool
490 operator!=(basic_string_view<_CharT, _Traits> __x,
491 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
492 { return !(__x == __y); }
493
494 template<typename _CharT, typename _Traits>
495 constexpr bool
496 operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
497 basic_string_view<_CharT, _Traits> __y) noexcept
498 { return !(__x == __y); }
499
500 template<typename _CharT, typename _Traits>
501 constexpr bool
502 operator< (basic_string_view<_CharT, _Traits> __x,
503 basic_string_view<_CharT, _Traits> __y) noexcept
504 { return __x.compare(__y) < 0; }
505
506 template<typename _CharT, typename _Traits>
507 constexpr bool
508 operator< (basic_string_view<_CharT, _Traits> __x,
509 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
510 { return __x.compare(__y) < 0; }
511
512 template<typename _CharT, typename _Traits>
513 constexpr bool
514 operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
515 basic_string_view<_CharT, _Traits> __y) noexcept
516 { return __x.compare(__y) < 0; }
517
518 template<typename _CharT, typename _Traits>
519 constexpr bool
520 operator> (basic_string_view<_CharT, _Traits> __x,
521 basic_string_view<_CharT, _Traits> __y) noexcept
522 { return __x.compare(__y) > 0; }
523
524 template<typename _CharT, typename _Traits>
525 constexpr bool
526 operator> (basic_string_view<_CharT, _Traits> __x,
527 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
528 { return __x.compare(__y) > 0; }
529
530 template<typename _CharT, typename _Traits>
531 constexpr bool
532 operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
533 basic_string_view<_CharT, _Traits> __y) noexcept
534 { return __x.compare(__y) > 0; }
535
536 template<typename _CharT, typename _Traits>
537 constexpr bool
538 operator<=(basic_string_view<_CharT, _Traits> __x,
539 basic_string_view<_CharT, _Traits> __y) noexcept
540 { return __x.compare(__y) <= 0; }
541
542 template<typename _CharT, typename _Traits>
543 constexpr bool
544 operator<=(basic_string_view<_CharT, _Traits> __x,
545 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
546 { return __x.compare(__y) <= 0; }
547
548 template<typename _CharT, typename _Traits>
549 constexpr bool
550 operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
551 basic_string_view<_CharT, _Traits> __y) noexcept
552 { return __x.compare(__y) <= 0; }
553
554 template<typename _CharT, typename _Traits>
555 constexpr bool
556 operator>=(basic_string_view<_CharT, _Traits> __x,
557 basic_string_view<_CharT, _Traits> __y) noexcept
558 { return __x.compare(__y) >= 0; }
559
560 template<typename _CharT, typename _Traits>
561 constexpr bool
562 operator>=(basic_string_view<_CharT, _Traits> __x,
563 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
564 { return __x.compare(__y) >= 0; }
565
566 template<typename _CharT, typename _Traits>
567 constexpr bool
568 operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
569 basic_string_view<_CharT, _Traits> __y) noexcept
570 { return __x.compare(__y) >= 0; }
571
572 // [string.view.io], Inserters and extractors
573 template<typename _CharT, typename _Traits>
574 inline basic_ostream<_CharT, _Traits>&
575 operator<<(basic_ostream<_CharT, _Traits>& __os,
576 basic_string_view<_CharT,_Traits> __str)
577 { return __ostream_insert(__os, __str.data(), __str.size()); }
578
579
580 // basic_string_view typedef names
581
582 using string_view = basic_string_view<char>;
583 #ifdef _GLIBCXX_USE_WCHAR_T
584 using wstring_view = basic_string_view<wchar_t>;
585 #endif
586 #ifdef _GLIBCXX_USE_CHAR8_T
587 using u8string_view = basic_string_view<char8_t>;
588 #endif
589 using u16string_view = basic_string_view<char16_t>;
590 using u32string_view = basic_string_view<char32_t>;
591
592 // [string.view.hash], hash support:
593
594 template<typename _Tp>
595 struct hash;
596
597 template<>
598 struct hash<string_view>
599 : public __hash_base<size_t, string_view>
600 {
601 size_t
602 operator()(const string_view& __str) const noexcept
603 { return std::_Hash_impl::hash(__str.data(), __str.length()); }
604 };
605
606 template<>
607 struct __is_fast_hash<hash<string_view>> : std::false_type
608 { };
609
610 #ifdef _GLIBCXX_USE_WCHAR_T
611 template<>
612 struct hash<wstring_view>
613 : public __hash_base<size_t, wstring>
614 {
615 size_t
616 operator()(const wstring_view& __s) const noexcept
617 { return std::_Hash_impl::hash(__s.data(),
618 __s.length() * sizeof(wchar_t)); }
619 };
620
621 template<>
622 struct __is_fast_hash<hash<wstring_view>> : std::false_type
623 { };
624 #endif
625
626 #ifdef _GLIBCXX_USE_CHAR8_T
627 template<>
628 struct hash<u8string_view>
629 : public __hash_base<size_t, u8string_view>
630 {
631 size_t
632 operator()(const u8string_view& __str) const noexcept
633 { return std::_Hash_impl::hash(__str.data(), __str.length()); }
634 };
635
636 template<>
637 struct __is_fast_hash<hash<u8string_view>> : std::false_type
638 { };
639 #endif
640
641 template<>
642 struct hash<u16string_view>
643 : public __hash_base<size_t, u16string_view>
644 {
645 size_t
646 operator()(const u16string_view& __s) const noexcept
647 { return std::_Hash_impl::hash(__s.data(),
648 __s.length() * sizeof(char16_t)); }
649 };
650
651 template<>
652 struct __is_fast_hash<hash<u16string_view>> : std::false_type
653 { };
654
655 template<>
656 struct hash<u32string_view>
657 : public __hash_base<size_t, u32string_view>
658 {
659 size_t
660 operator()(const u32string_view& __s) const noexcept
661 { return std::_Hash_impl::hash(__s.data(),
662 __s.length() * sizeof(char32_t)); }
663 };
664
665 template<>
666 struct __is_fast_hash<hash<u32string_view>> : std::false_type
667 { };
668
669 inline namespace literals
670 {
671 inline namespace string_view_literals
672 {
673 #pragma GCC diagnostic push
674 #pragma GCC diagnostic ignored "-Wliteral-suffix"
675 inline constexpr basic_string_view<char>
676 operator""sv(const char* __str, size_t __len) noexcept
677 { return basic_string_view<char>{__str, __len}; }
678
679 #ifdef _GLIBCXX_USE_WCHAR_T
680 inline constexpr basic_string_view<wchar_t>
681 operator""sv(const wchar_t* __str, size_t __len) noexcept
682 { return basic_string_view<wchar_t>{__str, __len}; }
683 #endif
684
685 #ifdef _GLIBCXX_USE_CHAR8_T
686 inline constexpr basic_string_view<char8_t>
687 operator""sv(const char8_t* __str, size_t __len) noexcept
688 { return basic_string_view<char8_t>{__str, __len}; }
689 #endif
690
691 inline constexpr basic_string_view<char16_t>
692 operator""sv(const char16_t* __str, size_t __len) noexcept
693 { return basic_string_view<char16_t>{__str, __len}; }
694
695 inline constexpr basic_string_view<char32_t>
696 operator""sv(const char32_t* __str, size_t __len) noexcept
697 { return basic_string_view<char32_t>{__str, __len}; }
698
699 #pragma GCC diagnostic pop
700 } // namespace string_literals
701 } // namespace literals
702
703 _GLIBCXX_END_NAMESPACE_VERSION
704 } // namespace std
705
706 #include <bits/string_view.tcc>
707
708 #endif // __cplusplus <= 201402L
709
710 #endif // _GLIBCXX_EXPERIMENTAL_STRING_VIEW