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-2015 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 
00045 namespace std _GLIBCXX_VISIBILITY(default)
00046 {
00047 namespace experimental
00048 {
00049 inline namespace fundamentals_v1
00050 {
00051 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00052 
00053 #define __cpp_lib_experimental_string_view 201411
00054 
00055   /**
00056    *  @class basic_string_view <experimental/string_view>
00057    *  @brief  A non-owning reference to a string.
00058    *
00059    *  @ingroup strings
00060    *  @ingroup sequences
00061    *  @ingroup experimental
00062    *
00063    *  @tparam _CharT  Type of character
00064    *  @tparam _Traits  Traits for character type, defaults to
00065    *                   char_traits<_CharT>.
00066    *
00067    *  A basic_string_view looks like this:
00068    *
00069    *  @code
00070    *    _CharT*    _M_str
00071    *    size_t     _M_len
00072    *  @endcode
00073    */
00074   template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
00075     class basic_string_view
00076     {
00077     public:
00078 
00079       // types
00080       using traits_type = _Traits;
00081       using value_type = _CharT;
00082       using pointer = const _CharT*;
00083       using const_pointer = const _CharT*;
00084       using reference = const _CharT&;
00085       using const_reference = const _CharT&;
00086       using const_iterator = const _CharT*;
00087       using iterator = const_iterator;
00088       using const_reverse_iterator = std::reverse_iterator<const_iterator>;
00089       using reverse_iterator = const_reverse_iterator;
00090       using size_type = size_t;
00091       using difference_type = ptrdiff_t;
00092       static constexpr size_type npos = size_type(-1);
00093 
00094       // [string.view.cons], construct/copy
00095 
00096       constexpr
00097       basic_string_view() noexcept
00098       : _M_len{0}, _M_str{nullptr}
00099       { }
00100 
00101       constexpr basic_string_view(const basic_string_view&) noexcept = default;
00102 
00103       template<typename _Allocator>
00104         basic_string_view(const basic_string<_CharT, _Traits,
00105                           _Allocator>& __str) noexcept
00106         : _M_len{__str.length()}, _M_str{__str.data()}
00107         { }
00108 
00109       constexpr basic_string_view(const _CharT* __str)
00110       : _M_len{__str == nullptr ? 0 : traits_type::length(__str)},
00111         _M_str{__str}
00112       { }
00113 
00114       constexpr basic_string_view(const _CharT* __str, size_type __len)
00115       : _M_len{__len},
00116         _M_str{__str}
00117       { }
00118 
00119       basic_string_view&
00120       operator=(const basic_string_view&) noexcept = default;
00121 
00122       // [string.view.iterators], iterators
00123 
00124       constexpr const_iterator
00125       begin() const noexcept
00126       { return this->_M_str; }
00127 
00128       constexpr const_iterator
00129       end() const noexcept
00130       { return this->_M_str + this->_M_len; }
00131 
00132       constexpr const_iterator
00133       cbegin() const noexcept
00134       { return this->_M_str; }
00135 
00136       constexpr const_iterator
00137       cend() const noexcept
00138       { return this->_M_str + this->_M_len; }
00139 
00140       const_reverse_iterator
00141       rbegin() const noexcept
00142       { return const_reverse_iterator(this->end()); }
00143 
00144       const_reverse_iterator
00145       rend() const noexcept
00146       { return const_reverse_iterator(this->begin()); }
00147 
00148       const_reverse_iterator
00149       crbegin() const noexcept
00150       { return const_reverse_iterator(this->end()); }
00151 
00152       const_reverse_iterator
00153       crend() const noexcept
00154       { return const_reverse_iterator(this->begin()); }
00155 
00156       // [string.view.capacity], capacity
00157 
00158       constexpr size_type
00159       size() const noexcept
00160       { return this->_M_len; }
00161 
00162       constexpr size_type
00163       length() const noexcept
00164       { return _M_len; }
00165 
00166       constexpr size_type
00167       max_size() const noexcept
00168       {
00169         return (npos - sizeof(size_type) - sizeof(void*))
00170                 / sizeof(value_type) / 4;
00171       }
00172 
00173       constexpr bool
00174       empty() const noexcept
00175       { return this->_M_len == 0; }
00176 
00177       // [string.view.access], element access
00178 
00179       constexpr const _CharT&
00180       operator[](size_type __pos) const
00181       {
00182         // TODO: Assert to restore in a way compatible with the constexpr.
00183         // _GLIBCXX_DEBUG_ASSERT(__pos < this->_M_len);
00184         return *(this->_M_str + __pos);
00185       }
00186 
00187       constexpr const _CharT&
00188       at(size_type __pos) const
00189       {
00190         return __pos < this->_M_len
00191              ? *(this->_M_str + __pos)
00192              : (__throw_out_of_range_fmt(__N("basic_string_view::at: __pos "
00193                                              "(which is %zu) >= this->size() "
00194                                              "(which is %zu)"),
00195                                          __pos, this->size()),
00196                 *this->_M_str);
00197       }
00198 
00199       constexpr const _CharT&
00200       front() const
00201       {
00202         // TODO: Assert to restore in a way compatible with the constexpr.
00203         // _GLIBCXX_DEBUG_ASSERT(this->_M_len > 0);
00204         return *this->_M_str;
00205       }
00206 
00207       constexpr const _CharT&
00208       back() const
00209       {
00210         // TODO: Assert to restore in a way compatible with the constexpr.
00211         // _GLIBCXX_DEBUG_ASSERT(this->_M_len > 0);
00212         return *(this->_M_str + this->_M_len - 1);
00213       }
00214 
00215       constexpr const _CharT*
00216       data() const noexcept
00217       { return this->_M_str; }
00218 
00219       // [string.view.modifiers], modifiers:
00220 
00221       void
00222       remove_prefix(size_type __n)
00223       {
00224         _GLIBCXX_DEBUG_ASSERT(this->_M_len >= __n);
00225         this->_M_str += __n;
00226         this->_M_len -= __n;
00227       }
00228 
00229       void
00230       remove_suffix(size_type __n)
00231       { this->_M_len -= __n; }
00232 
00233       void
00234       swap(basic_string_view& __sv) noexcept
00235       {
00236         std::swap(this->_M_len, __sv._M_len);
00237         std::swap(this->_M_str, __sv._M_str);
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, 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       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       int
00298       compare(size_type __pos1, size_type __n1, basic_string_view __str) const
00299       { return this->substr(__pos1, __n1).compare(__str); }
00300 
00301       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       int
00307       compare(const _CharT* __str) const noexcept
00308       { return this->compare(basic_string_view{__str}); }
00309 
00310       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       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       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       size_type
00327       find(_CharT __c, size_type __pos=0) const noexcept;
00328 
00329       size_type
00330       find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
00331 
00332       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       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       size_type
00341       rfind(_CharT __c, size_type __pos = npos) const noexcept;
00342 
00343       size_type
00344       rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
00345 
00346       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       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       size_type
00355       find_first_of(_CharT __c, size_type __pos = 0) const noexcept
00356       { return this->find(__c, __pos); }
00357 
00358       size_type
00359       find_first_of(const _CharT* __str, size_type __pos, size_type __n) const;
00360 
00361       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       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       size_type
00371       find_last_of(_CharT __c, size_type __pos=npos) const noexcept
00372       { return this->rfind(__c, __pos); }
00373 
00374       size_type
00375       find_last_of(const _CharT* __str, size_type __pos, size_type __n) const;
00376 
00377       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       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       size_type
00387       find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
00388 
00389       size_type
00390       find_first_not_of(const _CharT* __str,
00391                         size_type __pos, size_type __n) const;
00392 
00393       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       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       size_type
00406       find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
00407 
00408       size_type
00409       find_last_not_of(const _CharT* __str,
00410                        size_type __pos, size_type __n) const;
00411 
00412       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 const 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 
00437   // [string.view.comparison], non-member basic_string_view comparison functions
00438 
00439   namespace __detail
00440   {
00441     //  Identity transform to make ADL work with just one argument.
00442     //  See n3766.html.
00443     template<typename _Tp = void>
00444       struct __identity
00445       { typedef _Tp type; };
00446 
00447     template<>
00448       struct __identity<void>;
00449 
00450     template<typename _Tp>
00451       using __idt = typename __identity<_Tp>::type;
00452   }
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.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.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.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 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00655 
00656   // I added these EMSR.
00657   inline namespace literals
00658   {
00659   inline namespace string_view_literals
00660   {
00661 
00662     inline constexpr basic_string_view<char>
00663     operator""sv(const char* __str, size_t __len)
00664     { return basic_string_view<char>{__str, __len}; }
00665 
00666 #ifdef _GLIBCXX_USE_WCHAR_T
00667     inline constexpr basic_string_view<wchar_t>
00668     operator""sv(const wchar_t* __str, size_t __len)
00669     { return basic_string_view<wchar_t>{__str, __len}; }
00670 #endif
00671 
00672 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
00673     inline constexpr basic_string_view<char16_t>
00674     operator""sv(const char16_t* __str, size_t __len)
00675     { return basic_string_view<char16_t>{__str, __len}; }
00676 
00677     inline constexpr basic_string_view<char32_t>
00678     operator""sv(const char32_t* __str, size_t __len)
00679     { return basic_string_view<char32_t>{__str, __len}; }
00680 #endif
00681 
00682   }
00683   }
00684 
00685 _GLIBCXX_END_NAMESPACE_VERSION
00686 } // namespace experimental
00687 } // namespace std
00688 
00689 #include <experimental/string_view.tcc>
00690 
00691 #endif // __cplusplus <= 201103L
00692 
00693 #endif // _GLIBCXX_EXPERIMENTAL_STRING_VIEW