libstdc++
|
00001 // Components for manipulating non-owning sequences of characters -*- C++ -*- 00002 00003 // Copyright (C) 2013-2019 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file experimental/string_view 00026 * This is a TS C++ Library header. 00027 */ 00028 00029 // 00030 // N3762 basic_string_view library 00031 // 00032 00033 #ifndef _GLIBCXX_EXPERIMENTAL_STRING_VIEW 00034 #define _GLIBCXX_EXPERIMENTAL_STRING_VIEW 1 00035 00036 #pragma GCC system_header 00037 00038 #if __cplusplus >= 201402L 00039 00040 #include <string> 00041 #include <limits> 00042 #include <experimental/bits/lfts_config.h> 00043 00044 namespace std _GLIBCXX_VISIBILITY(default) 00045 { 00046 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00047 00048 namespace experimental 00049 { 00050 inline namespace fundamentals_v1 00051 { 00052 #define __cpp_lib_experimental_string_view 201411 00053 00054 /** 00055 * @class basic_string_view <experimental/string_view> 00056 * @brief A non-owning reference to a string. 00057 * 00058 * @ingroup strings 00059 * @ingroup sequences 00060 * @ingroup experimental 00061 * 00062 * @tparam _CharT Type of character 00063 * @tparam _Traits Traits for character type, defaults to 00064 * char_traits<_CharT>. 00065 * 00066 * A basic_string_view looks like this: 00067 * 00068 * @code 00069 * _CharT* _M_str 00070 * size_t _M_len 00071 * @endcode 00072 */ 00073 template<typename _CharT, typename _Traits = std::char_traits<_CharT>> 00074 class basic_string_view 00075 { 00076 public: 00077 00078 // types 00079 using traits_type = _Traits; 00080 using value_type = _CharT; 00081 using pointer = _CharT*; 00082 using const_pointer = const _CharT*; 00083 using reference = _CharT&; 00084 using const_reference = const _CharT&; 00085 using const_iterator = const _CharT*; 00086 using iterator = const_iterator; 00087 using const_reverse_iterator = std::reverse_iterator<const_iterator>; 00088 using reverse_iterator = const_reverse_iterator; 00089 using size_type = size_t; 00090 using difference_type = ptrdiff_t; 00091 static constexpr size_type npos = size_type(-1); 00092 00093 // [string.view.cons], construct/copy 00094 00095 constexpr 00096 basic_string_view() noexcept 00097 : _M_len{0}, _M_str{nullptr} 00098 { } 00099 00100 constexpr basic_string_view(const basic_string_view&) noexcept = default; 00101 00102 template<typename _Allocator> 00103 basic_string_view(const basic_string<_CharT, _Traits, 00104 _Allocator>& __str) noexcept 00105 : _M_len{__str.length()}, _M_str{__str.data()} 00106 { } 00107 00108 constexpr basic_string_view(const _CharT* __str) 00109 : _M_len{__str == nullptr ? 0 : traits_type::length(__str)}, 00110 _M_str{__str} 00111 { } 00112 00113 constexpr basic_string_view(const _CharT* __str, size_type __len) 00114 : _M_len{__len}, 00115 _M_str{__str} 00116 { } 00117 00118 basic_string_view& 00119 operator=(const basic_string_view&) noexcept = default; 00120 00121 // [string.view.iterators], iterators 00122 00123 constexpr const_iterator 00124 begin() const noexcept 00125 { return this->_M_str; } 00126 00127 constexpr const_iterator 00128 end() const noexcept 00129 { return this->_M_str + this->_M_len; } 00130 00131 constexpr const_iterator 00132 cbegin() const noexcept 00133 { return this->_M_str; } 00134 00135 constexpr const_iterator 00136 cend() const noexcept 00137 { return this->_M_str + this->_M_len; } 00138 00139 const_reverse_iterator 00140 rbegin() const noexcept 00141 { return const_reverse_iterator(this->end()); } 00142 00143 const_reverse_iterator 00144 rend() const noexcept 00145 { return const_reverse_iterator(this->begin()); } 00146 00147 const_reverse_iterator 00148 crbegin() const noexcept 00149 { return const_reverse_iterator(this->end()); } 00150 00151 const_reverse_iterator 00152 crend() const noexcept 00153 { return const_reverse_iterator(this->begin()); } 00154 00155 // [string.view.capacity], capacity 00156 00157 constexpr size_type 00158 size() const noexcept 00159 { return this->_M_len; } 00160 00161 constexpr size_type 00162 length() const noexcept 00163 { return _M_len; } 00164 00165 constexpr size_type 00166 max_size() const noexcept 00167 { 00168 return (npos - sizeof(size_type) - sizeof(void*)) 00169 / sizeof(value_type) / 4; 00170 } 00171 00172 _GLIBCXX_NODISCARD constexpr bool 00173 empty() const noexcept 00174 { return this->_M_len == 0; } 00175 00176 // [string.view.access], element access 00177 00178 constexpr const _CharT& 00179 operator[](size_type __pos) const 00180 { 00181 // TODO: Assert to restore in a way compatible with the constexpr. 00182 // __glibcxx_assert(__pos < this->_M_len); 00183 return *(this->_M_str + __pos); 00184 } 00185 00186 constexpr const _CharT& 00187 at(size_type __pos) const 00188 { 00189 return __pos < this->_M_len 00190 ? *(this->_M_str + __pos) 00191 : (__throw_out_of_range_fmt(__N("basic_string_view::at: __pos " 00192 "(which is %zu) >= this->size() " 00193 "(which is %zu)"), 00194 __pos, this->size()), 00195 *this->_M_str); 00196 } 00197 00198 constexpr const _CharT& 00199 front() const 00200 { 00201 // TODO: Assert to restore in a way compatible with the constexpr. 00202 // __glibcxx_assert(this->_M_len > 0); 00203 return *this->_M_str; 00204 } 00205 00206 constexpr const _CharT& 00207 back() const 00208 { 00209 // TODO: Assert to restore in a way compatible with the constexpr. 00210 // __glibcxx_assert(this->_M_len > 0); 00211 return *(this->_M_str + this->_M_len - 1); 00212 } 00213 00214 constexpr const _CharT* 00215 data() const noexcept 00216 { return this->_M_str; } 00217 00218 // [string.view.modifiers], modifiers: 00219 00220 constexpr void 00221 remove_prefix(size_type __n) 00222 { 00223 __glibcxx_assert(this->_M_len >= __n); 00224 this->_M_str += __n; 00225 this->_M_len -= __n; 00226 } 00227 00228 constexpr void 00229 remove_suffix(size_type __n) 00230 { this->_M_len -= __n; } 00231 00232 constexpr void 00233 swap(basic_string_view& __sv) noexcept 00234 { 00235 auto __tmp = *this; 00236 *this = __sv; 00237 __sv = __tmp; 00238 } 00239 00240 00241 // [string.view.ops], string operations: 00242 00243 template<typename _Allocator> 00244 explicit operator basic_string<_CharT, _Traits, _Allocator>() const 00245 { 00246 return { this->_M_str, this->_M_len }; 00247 } 00248 00249 template<typename _Allocator = std::allocator<_CharT>> 00250 basic_string<_CharT, _Traits, _Allocator> 00251 to_string(const _Allocator& __alloc = _Allocator()) const 00252 { 00253 return { this->_M_str, this->_M_len, __alloc }; 00254 } 00255 00256 size_type 00257 copy(_CharT* __str, size_type __n, size_type __pos = 0) const 00258 { 00259 __glibcxx_requires_string_len(__str, __n); 00260 if (__pos > this->_M_len) 00261 __throw_out_of_range_fmt(__N("basic_string_view::copy: __pos " 00262 "(which is %zu) > this->size() " 00263 "(which is %zu)"), 00264 __pos, this->size()); 00265 size_type __rlen{std::min(__n, size_type{this->_M_len - __pos})}; 00266 for (auto __begin = this->_M_str + __pos, 00267 __end = __begin + __rlen; __begin != __end;) 00268 *__str++ = *__begin++; 00269 return __rlen; 00270 } 00271 00272 00273 // [string.view.ops], string operations: 00274 00275 constexpr basic_string_view 00276 substr(size_type __pos = 0, size_type __n = npos) const 00277 { 00278 return __pos <= this->_M_len 00279 ? basic_string_view{this->_M_str + __pos, 00280 std::min(__n, size_type{this->_M_len - __pos})} 00281 : (__throw_out_of_range_fmt(__N("basic_string_view::substr: __pos " 00282 "(which is %zu) > this->size() " 00283 "(which is %zu)"), 00284 __pos, this->size()), basic_string_view{}); 00285 } 00286 00287 constexpr int 00288 compare(basic_string_view __str) const noexcept 00289 { 00290 int __ret = traits_type::compare(this->_M_str, __str._M_str, 00291 std::min(this->_M_len, __str._M_len)); 00292 if (__ret == 0) 00293 __ret = _S_compare(this->_M_len, __str._M_len); 00294 return __ret; 00295 } 00296 00297 constexpr int 00298 compare(size_type __pos1, size_type __n1, basic_string_view __str) const 00299 { return this->substr(__pos1, __n1).compare(__str); } 00300 00301 constexpr int 00302 compare(size_type __pos1, size_type __n1, 00303 basic_string_view __str, size_type __pos2, size_type __n2) const 00304 { return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); } 00305 00306 constexpr int 00307 compare(const _CharT* __str) const noexcept 00308 { return this->compare(basic_string_view{__str}); } 00309 00310 constexpr int 00311 compare(size_type __pos1, size_type __n1, const _CharT* __str) const 00312 { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); } 00313 00314 constexpr int 00315 compare(size_type __pos1, size_type __n1, 00316 const _CharT* __str, size_type __n2) const 00317 { 00318 return this->substr(__pos1, __n1) 00319 .compare(basic_string_view(__str, __n2)); 00320 } 00321 00322 constexpr size_type 00323 find(basic_string_view __str, size_type __pos = 0) const noexcept 00324 { return this->find(__str._M_str, __pos, __str._M_len); } 00325 00326 constexpr size_type 00327 find(_CharT __c, size_type __pos=0) const noexcept; 00328 00329 constexpr size_type 00330 find(const _CharT* __str, size_type __pos, size_type __n) const noexcept; 00331 00332 constexpr size_type 00333 find(const _CharT* __str, size_type __pos=0) const noexcept 00334 { return this->find(__str, __pos, traits_type::length(__str)); } 00335 00336 constexpr size_type 00337 rfind(basic_string_view __str, size_type __pos = npos) const noexcept 00338 { return this->rfind(__str._M_str, __pos, __str._M_len); } 00339 00340 constexpr size_type 00341 rfind(_CharT __c, size_type __pos = npos) const noexcept; 00342 00343 constexpr size_type 00344 rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept; 00345 00346 constexpr size_type 00347 rfind(const _CharT* __str, size_type __pos = npos) const noexcept 00348 { return this->rfind(__str, __pos, traits_type::length(__str)); } 00349 00350 constexpr size_type 00351 find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept 00352 { return this->find_first_of(__str._M_str, __pos, __str._M_len); } 00353 00354 constexpr size_type 00355 find_first_of(_CharT __c, size_type __pos = 0) const noexcept 00356 { return this->find(__c, __pos); } 00357 00358 constexpr size_type 00359 find_first_of(const _CharT* __str, size_type __pos, size_type __n) const; 00360 00361 constexpr size_type 00362 find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept 00363 { return this->find_first_of(__str, __pos, traits_type::length(__str)); } 00364 00365 constexpr size_type 00366 find_last_of(basic_string_view __str, 00367 size_type __pos = npos) const noexcept 00368 { return this->find_last_of(__str._M_str, __pos, __str._M_len); } 00369 00370 constexpr size_type 00371 find_last_of(_CharT __c, size_type __pos=npos) const noexcept 00372 { return this->rfind(__c, __pos); } 00373 00374 constexpr size_type 00375 find_last_of(const _CharT* __str, size_type __pos, size_type __n) const; 00376 00377 constexpr size_type 00378 find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept 00379 { return this->find_last_of(__str, __pos, traits_type::length(__str)); } 00380 00381 constexpr size_type 00382 find_first_not_of(basic_string_view __str, 00383 size_type __pos = 0) const noexcept 00384 { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); } 00385 00386 constexpr size_type 00387 find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept; 00388 00389 constexpr size_type 00390 find_first_not_of(const _CharT* __str, 00391 size_type __pos, size_type __n) const; 00392 00393 constexpr size_type 00394 find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept 00395 { 00396 return this->find_first_not_of(__str, __pos, 00397 traits_type::length(__str)); 00398 } 00399 00400 constexpr size_type 00401 find_last_not_of(basic_string_view __str, 00402 size_type __pos = npos) const noexcept 00403 { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); } 00404 00405 constexpr size_type 00406 find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept; 00407 00408 constexpr size_type 00409 find_last_not_of(const _CharT* __str, 00410 size_type __pos, size_type __n) const; 00411 00412 constexpr size_type 00413 find_last_not_of(const _CharT* __str, 00414 size_type __pos = npos) const noexcept 00415 { 00416 return this->find_last_not_of(__str, __pos, 00417 traits_type::length(__str)); 00418 } 00419 00420 private: 00421 00422 static constexpr int 00423 _S_compare(size_type __n1, size_type __n2) noexcept 00424 { 00425 return difference_type(__n1 - __n2) > std::numeric_limits<int>::max() 00426 ? std::numeric_limits<int>::max() 00427 : difference_type(__n1 - __n2) < std::numeric_limits<int>::min() 00428 ? std::numeric_limits<int>::min() 00429 : static_cast<int>(difference_type(__n1 - __n2)); 00430 } 00431 00432 size_t _M_len; 00433 const _CharT* _M_str; 00434 }; 00435 00436 // [string.view.comparison], non-member basic_string_view comparison functions 00437 00438 namespace __detail 00439 { 00440 // Identity transform to create a non-deduced context, so that only one 00441 // argument participates in template argument deduction and the other 00442 // argument gets implicitly converted to the deduced type. See n3766.html. 00443 template<typename _Tp> 00444 using __idt = common_type_t<_Tp>; 00445 } 00446 00447 template<typename _CharT, typename _Traits> 00448 constexpr bool 00449 operator==(basic_string_view<_CharT, _Traits> __x, 00450 basic_string_view<_CharT, _Traits> __y) noexcept 00451 { return __x.size() == __y.size() && __x.compare(__y) == 0; } 00452 00453 template<typename _CharT, typename _Traits> 00454 constexpr bool 00455 operator==(basic_string_view<_CharT, _Traits> __x, 00456 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept 00457 { return __x.size() == __y.size() && __x.compare(__y) == 0; } 00458 00459 template<typename _CharT, typename _Traits> 00460 constexpr bool 00461 operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, 00462 basic_string_view<_CharT, _Traits> __y) noexcept 00463 { return __x.size() == __y.size() && __x.compare(__y) == 0; } 00464 00465 template<typename _CharT, typename _Traits> 00466 constexpr bool 00467 operator!=(basic_string_view<_CharT, _Traits> __x, 00468 basic_string_view<_CharT, _Traits> __y) noexcept 00469 { return !(__x == __y); } 00470 00471 template<typename _CharT, typename _Traits> 00472 constexpr bool 00473 operator!=(basic_string_view<_CharT, _Traits> __x, 00474 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept 00475 { return !(__x == __y); } 00476 00477 template<typename _CharT, typename _Traits> 00478 constexpr bool 00479 operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, 00480 basic_string_view<_CharT, _Traits> __y) noexcept 00481 { return !(__x == __y); } 00482 00483 template<typename _CharT, typename _Traits> 00484 constexpr bool 00485 operator< (basic_string_view<_CharT, _Traits> __x, 00486 basic_string_view<_CharT, _Traits> __y) noexcept 00487 { return __x.compare(__y) < 0; } 00488 00489 template<typename _CharT, typename _Traits> 00490 constexpr bool 00491 operator< (basic_string_view<_CharT, _Traits> __x, 00492 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept 00493 { return __x.compare(__y) < 0; } 00494 00495 template<typename _CharT, typename _Traits> 00496 constexpr bool 00497 operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x, 00498 basic_string_view<_CharT, _Traits> __y) noexcept 00499 { return __x.compare(__y) < 0; } 00500 00501 template<typename _CharT, typename _Traits> 00502 constexpr bool 00503 operator> (basic_string_view<_CharT, _Traits> __x, 00504 basic_string_view<_CharT, _Traits> __y) noexcept 00505 { return __x.compare(__y) > 0; } 00506 00507 template<typename _CharT, typename _Traits> 00508 constexpr bool 00509 operator> (basic_string_view<_CharT, _Traits> __x, 00510 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept 00511 { return __x.compare(__y) > 0; } 00512 00513 template<typename _CharT, typename _Traits> 00514 constexpr bool 00515 operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x, 00516 basic_string_view<_CharT, _Traits> __y) noexcept 00517 { return __x.compare(__y) > 0; } 00518 00519 template<typename _CharT, typename _Traits> 00520 constexpr bool 00521 operator<=(basic_string_view<_CharT, _Traits> __x, 00522 basic_string_view<_CharT, _Traits> __y) noexcept 00523 { return __x.compare(__y) <= 0; } 00524 00525 template<typename _CharT, typename _Traits> 00526 constexpr bool 00527 operator<=(basic_string_view<_CharT, _Traits> __x, 00528 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept 00529 { return __x.compare(__y) <= 0; } 00530 00531 template<typename _CharT, typename _Traits> 00532 constexpr bool 00533 operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, 00534 basic_string_view<_CharT, _Traits> __y) noexcept 00535 { return __x.compare(__y) <= 0; } 00536 00537 template<typename _CharT, typename _Traits> 00538 constexpr bool 00539 operator>=(basic_string_view<_CharT, _Traits> __x, 00540 basic_string_view<_CharT, _Traits> __y) noexcept 00541 { return __x.compare(__y) >= 0; } 00542 00543 template<typename _CharT, typename _Traits> 00544 constexpr bool 00545 operator>=(basic_string_view<_CharT, _Traits> __x, 00546 __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept 00547 { return __x.compare(__y) >= 0; } 00548 00549 template<typename _CharT, typename _Traits> 00550 constexpr bool 00551 operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x, 00552 basic_string_view<_CharT, _Traits> __y) noexcept 00553 { return __x.compare(__y) >= 0; } 00554 00555 // [string.view.io], Inserters and extractors 00556 template<typename _CharT, typename _Traits> 00557 inline basic_ostream<_CharT, _Traits>& 00558 operator<<(basic_ostream<_CharT, _Traits>& __os, 00559 basic_string_view<_CharT,_Traits> __str) 00560 { return __ostream_insert(__os, __str.data(), __str.size()); } 00561 00562 00563 // basic_string_view typedef names 00564 00565 using string_view = basic_string_view<char>; 00566 #ifdef _GLIBCXX_USE_WCHAR_T 00567 using wstring_view = basic_string_view<wchar_t>; 00568 #endif 00569 #ifdef _GLIBCXX_USE_CHAR8_T 00570 using u8string_view = basic_string_view<char8_t>; 00571 #endif 00572 using u16string_view = basic_string_view<char16_t>; 00573 using u32string_view = basic_string_view<char32_t>; 00574 } // namespace fundamentals_v1 00575 } // namespace experimental 00576 00577 00578 // [string.view.hash], hash support: 00579 template<typename _Tp> 00580 struct hash; 00581 00582 template<> 00583 struct hash<experimental::string_view> 00584 : public __hash_base<size_t, experimental::string_view> 00585 { 00586 size_t 00587 operator()(const experimental::string_view& __str) const noexcept 00588 { return std::_Hash_impl::hash(__str.data(), __str.length()); } 00589 }; 00590 00591 template<> 00592 struct __is_fast_hash<hash<experimental::string_view>> : std::false_type 00593 { }; 00594 00595 #ifdef _GLIBCXX_USE_WCHAR_T 00596 template<> 00597 struct hash<experimental::wstring_view> 00598 : public __hash_base<size_t, wstring> 00599 { 00600 size_t 00601 operator()(const experimental::wstring_view& __s) const noexcept 00602 { return std::_Hash_impl::hash(__s.data(), 00603 __s.length() * sizeof(wchar_t)); } 00604 }; 00605 00606 template<> 00607 struct __is_fast_hash<hash<experimental::wstring_view>> : std::false_type 00608 { }; 00609 #endif 00610 00611 #ifdef _GLIBCXX_USE_CHAR8_T 00612 template<> 00613 struct hash<experimental::u8string_view> 00614 : public __hash_base<size_t, experimental::u8string_view> 00615 { 00616 size_t 00617 operator()(const experimental::u8string_view& __s) const noexcept 00618 { return std::_Hash_impl::hash(__s.data(), __s.length()); } 00619 }; 00620 00621 template<> 00622 struct __is_fast_hash<hash<experimental::u8string_view>> : std::false_type 00623 { }; 00624 #endif 00625 00626 template<> 00627 struct hash<experimental::u16string_view> 00628 : public __hash_base<size_t, experimental::u16string_view> 00629 { 00630 size_t 00631 operator()(const experimental::u16string_view& __s) const noexcept 00632 { return std::_Hash_impl::hash(__s.data(), 00633 __s.length() * sizeof(char16_t)); } 00634 }; 00635 00636 template<> 00637 struct __is_fast_hash<hash<experimental::u16string_view>> : std::false_type 00638 { }; 00639 00640 template<> 00641 struct hash<experimental::u32string_view> 00642 : public __hash_base<size_t, experimental::u32string_view> 00643 { 00644 size_t 00645 operator()(const experimental::u32string_view& __s) const noexcept 00646 { return std::_Hash_impl::hash(__s.data(), 00647 __s.length() * sizeof(char32_t)); } 00648 }; 00649 00650 template<> 00651 struct __is_fast_hash<hash<experimental::u32string_view>> : std::false_type 00652 { }; 00653 00654 namespace experimental 00655 { 00656 // I added these EMSR. 00657 inline namespace literals 00658 { 00659 inline namespace string_view_literals 00660 { 00661 #pragma GCC diagnostic push 00662 #pragma GCC diagnostic ignored "-Wliteral-suffix" 00663 inline constexpr basic_string_view<char> 00664 operator""sv(const char* __str, size_t __len) noexcept 00665 { return basic_string_view<char>{__str, __len}; } 00666 00667 #ifdef _GLIBCXX_USE_WCHAR_T 00668 inline constexpr basic_string_view<wchar_t> 00669 operator""sv(const wchar_t* __str, size_t __len) noexcept 00670 { return basic_string_view<wchar_t>{__str, __len}; } 00671 #endif 00672 00673 #ifdef _GLIBCXX_USE_CHAR8_T 00674 inline constexpr basic_string_view<char8_t> 00675 operator""sv(const char8_t* __str, size_t __len) noexcept 00676 { return basic_string_view<char8_t>{__str, __len}; } 00677 #endif 00678 00679 inline constexpr basic_string_view<char16_t> 00680 operator""sv(const char16_t* __str, size_t __len) noexcept 00681 { return basic_string_view<char16_t>{__str, __len}; } 00682 00683 inline constexpr basic_string_view<char32_t> 00684 operator""sv(const char32_t* __str, size_t __len) noexcept 00685 { return basic_string_view<char32_t>{__str, __len}; } 00686 #pragma GCC diagnostic pop 00687 } // namespace string_literals 00688 } // namespace literals 00689 } // namespace experimental 00690 00691 _GLIBCXX_END_NAMESPACE_VERSION 00692 } // namespace std 00693 00694 #include <experimental/bits/string_view.tcc> 00695 00696 #endif // __cplusplus <= 201103L 00697 00698 #endif // _GLIBCXX_EXPERIMENTAL_STRING_VIEW