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