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       constexpr 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       constexpr void
00231       remove_suffix(size_type __n)
00232       { this->_M_len -= __n; }
00233 
00234       constexpr void
00235       swap(basic_string_view& __sv) noexcept
00236       {
00237         auto __tmp = *this;
00238         *this = __sv;
00239         __sv = __tmp;
00240       }
00241 
00242 
00243       // [string.view.ops], string operations:
00244 
00245       template<typename _Allocator>
00246         explicit operator basic_string<_CharT, _Traits, _Allocator>() const
00247         {
00248           return { this->_M_str, this->_M_len };
00249         }
00250 
00251       template<typename _Allocator = std::allocator<_CharT>>
00252         basic_string<_CharT, _Traits, _Allocator>
00253         to_string(const _Allocator& __alloc = _Allocator()) const
00254         {
00255           return { this->_M_str, this->_M_len, __alloc };
00256         }
00257 
00258       size_type
00259       copy(_CharT* __str, size_type __n, size_type __pos = 0) const
00260       {
00261         __glibcxx_requires_string_len(__str, __n);
00262         if (__pos > this->_M_len)
00263           __throw_out_of_range_fmt(__N("basic_string_view::copy: __pos "
00264                                        "(which is %zu) > this->size() "
00265                                        "(which is %zu)"),
00266                                    __pos, this->size());
00267         size_type __rlen{std::min(__n, size_type{this->_M_len  - __pos})};
00268         for (auto __begin = this->_M_str + __pos,
00269              __end = __begin + __rlen; __begin != __end;)
00270           *__str++ = *__begin++;
00271         return __rlen;
00272       }
00273 
00274 
00275       // [string.view.ops], string operations:
00276 
00277       constexpr basic_string_view
00278       substr(size_type __pos, size_type __n=npos) const
00279       {
00280         return __pos <= this->_M_len
00281              ? basic_string_view{this->_M_str + __pos,
00282                                 std::min(__n, size_type{this->_M_len  - __pos})}
00283              : (__throw_out_of_range_fmt(__N("basic_string_view::substr: __pos "
00284                                              "(which is %zu) > this->size() "
00285                                              "(which is %zu)"),
00286                                      __pos, this->size()), basic_string_view{});
00287       }
00288 
00289       constexpr int
00290       compare(basic_string_view __str) const noexcept
00291       {
00292         int __ret = traits_type::compare(this->_M_str, __str._M_str,
00293                                          std::min(this->_M_len, __str._M_len));
00294         if (__ret == 0)
00295           __ret = _S_compare(this->_M_len, __str._M_len);
00296         return __ret;
00297       }
00298 
00299       constexpr int
00300       compare(size_type __pos1, size_type __n1, basic_string_view __str) const
00301       { return this->substr(__pos1, __n1).compare(__str); }
00302 
00303       constexpr int
00304       compare(size_type __pos1, size_type __n1,
00305               basic_string_view __str, size_type __pos2, size_type __n2) const
00306       { return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); }
00307 
00308       constexpr int
00309       compare(const _CharT* __str) const noexcept
00310       { return this->compare(basic_string_view{__str}); }
00311 
00312       constexpr int
00313       compare(size_type __pos1, size_type __n1, const _CharT* __str) const
00314       { return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
00315 
00316       constexpr int
00317       compare(size_type __pos1, size_type __n1,
00318               const _CharT* __str, size_type __n2) const
00319       {
00320         return this->substr(__pos1, __n1)
00321                    .compare(basic_string_view(__str, __n2));
00322       }
00323 
00324       constexpr size_type
00325       find(basic_string_view __str, size_type __pos = 0) const noexcept
00326       { return this->find(__str._M_str, __pos, __str._M_len); }
00327 
00328       constexpr size_type
00329       find(_CharT __c, size_type __pos=0) const noexcept;
00330 
00331       constexpr size_type
00332       find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
00333 
00334       constexpr size_type
00335       find(const _CharT* __str, size_type __pos=0) const noexcept
00336       { return this->find(__str, __pos, traits_type::length(__str)); }
00337 
00338       constexpr size_type
00339       rfind(basic_string_view __str, size_type __pos = npos) const noexcept
00340       { return this->rfind(__str._M_str, __pos, __str._M_len); }
00341 
00342       constexpr size_type
00343       rfind(_CharT __c, size_type __pos = npos) const noexcept;
00344 
00345       constexpr size_type
00346       rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
00347 
00348       constexpr size_type
00349       rfind(const _CharT* __str, size_type __pos = npos) const noexcept
00350       { return this->rfind(__str, __pos, traits_type::length(__str)); }
00351 
00352       constexpr size_type
00353       find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
00354       { return this->find_first_of(__str._M_str, __pos, __str._M_len); }
00355 
00356       constexpr size_type
00357       find_first_of(_CharT __c, size_type __pos = 0) const noexcept
00358       { return this->find(__c, __pos); }
00359 
00360       constexpr size_type
00361       find_first_of(const _CharT* __str, size_type __pos, size_type __n) const;
00362 
00363       constexpr size_type
00364       find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
00365       { return this->find_first_of(__str, __pos, traits_type::length(__str)); }
00366 
00367       constexpr size_type
00368       find_last_of(basic_string_view __str,
00369                    size_type __pos = npos) const noexcept
00370       { return this->find_last_of(__str._M_str, __pos, __str._M_len); }
00371 
00372       constexpr size_type
00373       find_last_of(_CharT __c, size_type __pos=npos) const noexcept
00374       { return this->rfind(__c, __pos); }
00375 
00376       constexpr size_type
00377       find_last_of(const _CharT* __str, size_type __pos, size_type __n) const;
00378 
00379       constexpr size_type
00380       find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
00381       { return this->find_last_of(__str, __pos, traits_type::length(__str)); }
00382 
00383       constexpr size_type
00384       find_first_not_of(basic_string_view __str,
00385                         size_type __pos = 0) const noexcept
00386       { return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
00387 
00388       constexpr size_type
00389       find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
00390 
00391       constexpr size_type
00392       find_first_not_of(const _CharT* __str,
00393                         size_type __pos, size_type __n) const;
00394 
00395       constexpr size_type
00396       find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
00397       {
00398         return this->find_first_not_of(__str, __pos,
00399                                        traits_type::length(__str));
00400       }
00401 
00402       constexpr size_type
00403       find_last_not_of(basic_string_view __str,
00404                        size_type __pos = npos) const noexcept
00405       { return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
00406 
00407       constexpr size_type
00408       find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
00409 
00410       constexpr size_type
00411       find_last_not_of(const _CharT* __str,
00412                        size_type __pos, size_type __n) const;
00413 
00414       constexpr size_type
00415       find_last_not_of(const _CharT* __str,
00416                        size_type __pos = npos) const noexcept
00417       {
00418         return this->find_last_not_of(__str, __pos,
00419                                       traits_type::length(__str));
00420       }
00421 
00422     private:
00423 
00424       static constexpr int
00425       _S_compare(size_type __n1, size_type __n2) noexcept
00426       {
00427         return difference_type{__n1 - __n2} > std::numeric_limits<int>::max()
00428              ? std::numeric_limits<int>::max()
00429              : difference_type{__n1 - __n2} < std::numeric_limits<int>::min()
00430              ? std::numeric_limits<int>::min()
00431              : static_cast<int>(difference_type{__n1 - __n2});
00432       }
00433 
00434       size_t        _M_len;
00435       const _CharT* _M_str;
00436     };
00437 
00438 _GLIBCXX_END_NAMESPACE_VERSION
00439 
00440   // [string.view.comparison], non-member basic_string_view comparison functions
00441 
00442   namespace __detail
00443   {
00444 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00445     // Identity transform to create a non-deduced context, so that only one
00446     // argument participates in template argument deduction and the other
00447     // argument gets implicitly converted to the deduced type. See n3766.html.
00448     template<typename _Tp>
00449       using __idt = common_type_t<_Tp>;
00450 _GLIBCXX_END_NAMESPACE_VERSION
00451   }
00452 
00453 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00454 
00455   template<typename _CharT, typename _Traits>
00456     constexpr bool
00457     operator==(basic_string_view<_CharT, _Traits> __x,
00458                basic_string_view<_CharT, _Traits> __y) noexcept
00459     { return __x.size() == __y.size() && __x.compare(__y) == 0; }
00460 
00461   template<typename _CharT, typename _Traits>
00462     constexpr bool
00463     operator==(basic_string_view<_CharT, _Traits> __x,
00464                __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
00465     { return __x.size() == __y.size() && __x.compare(__y) == 0; }
00466 
00467   template<typename _CharT, typename _Traits>
00468     constexpr bool
00469     operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
00470                basic_string_view<_CharT, _Traits> __y) noexcept
00471     { return __x.size() == __y.size() && __x.compare(__y) == 0; }
00472 
00473   template<typename _CharT, typename _Traits>
00474     constexpr bool
00475     operator!=(basic_string_view<_CharT, _Traits> __x,
00476                basic_string_view<_CharT, _Traits> __y) noexcept
00477     { return !(__x == __y); }
00478 
00479   template<typename _CharT, typename _Traits>
00480     constexpr bool
00481     operator!=(basic_string_view<_CharT, _Traits> __x,
00482                __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
00483     { return !(__x == __y); }
00484 
00485   template<typename _CharT, typename _Traits>
00486     constexpr bool
00487     operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
00488                basic_string_view<_CharT, _Traits> __y) noexcept
00489     { return !(__x == __y); }
00490 
00491   template<typename _CharT, typename _Traits>
00492     constexpr bool
00493     operator< (basic_string_view<_CharT, _Traits> __x,
00494                basic_string_view<_CharT, _Traits> __y) noexcept
00495     { return __x.compare(__y) < 0; }
00496 
00497   template<typename _CharT, typename _Traits>
00498     constexpr bool
00499     operator< (basic_string_view<_CharT, _Traits> __x,
00500                __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
00501     { return __x.compare(__y) < 0; }
00502 
00503   template<typename _CharT, typename _Traits>
00504     constexpr bool
00505     operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
00506                basic_string_view<_CharT, _Traits> __y) noexcept
00507     { return __x.compare(__y) < 0; }
00508 
00509   template<typename _CharT, typename _Traits>
00510     constexpr bool
00511     operator> (basic_string_view<_CharT, _Traits> __x,
00512                basic_string_view<_CharT, _Traits> __y) noexcept
00513     { return __x.compare(__y) > 0; }
00514 
00515   template<typename _CharT, typename _Traits>
00516     constexpr bool
00517     operator> (basic_string_view<_CharT, _Traits> __x,
00518                __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
00519     { return __x.compare(__y) > 0; }
00520 
00521   template<typename _CharT, typename _Traits>
00522     constexpr bool
00523     operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
00524                basic_string_view<_CharT, _Traits> __y) noexcept
00525     { return __x.compare(__y) > 0; }
00526 
00527   template<typename _CharT, typename _Traits>
00528     constexpr bool
00529     operator<=(basic_string_view<_CharT, _Traits> __x,
00530                basic_string_view<_CharT, _Traits> __y) noexcept
00531     { return __x.compare(__y) <= 0; }
00532 
00533   template<typename _CharT, typename _Traits>
00534     constexpr bool
00535     operator<=(basic_string_view<_CharT, _Traits> __x,
00536                __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
00537     { return __x.compare(__y) <= 0; }
00538 
00539   template<typename _CharT, typename _Traits>
00540     constexpr bool
00541     operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
00542                basic_string_view<_CharT, _Traits> __y) noexcept
00543     { return __x.compare(__y) <= 0; }
00544 
00545   template<typename _CharT, typename _Traits>
00546     constexpr bool
00547     operator>=(basic_string_view<_CharT, _Traits> __x,
00548                basic_string_view<_CharT, _Traits> __y) noexcept
00549     { return __x.compare(__y) >= 0; }
00550 
00551   template<typename _CharT, typename _Traits>
00552     constexpr bool
00553     operator>=(basic_string_view<_CharT, _Traits> __x,
00554                __detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
00555     { return __x.compare(__y) >= 0; }
00556 
00557   template<typename _CharT, typename _Traits>
00558     constexpr bool
00559     operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
00560                basic_string_view<_CharT, _Traits> __y) noexcept
00561     { return __x.compare(__y) >= 0; }
00562 
00563   // [string.view.io], Inserters and extractors
00564   template<typename _CharT, typename _Traits>
00565     inline basic_ostream<_CharT, _Traits>&
00566     operator<<(basic_ostream<_CharT, _Traits>& __os,
00567                basic_string_view<_CharT,_Traits> __str)
00568     { return __ostream_insert(__os, __str.data(), __str.size()); }
00569 
00570 
00571   // basic_string_view typedef names
00572 
00573   using string_view = basic_string_view<char>;
00574 #ifdef _GLIBCXX_USE_WCHAR_T
00575   using wstring_view = basic_string_view<wchar_t>;
00576 #endif
00577 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
00578   using u16string_view = basic_string_view<char16_t>;
00579   using u32string_view = basic_string_view<char32_t>;
00580 #endif
00581 
00582 _GLIBCXX_END_NAMESPACE_VERSION
00583 } // namespace fundamentals_v1
00584 } // namespace experimental
00585 
00586 
00587   // [string.view.hash], hash support:
00588 
00589 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00590   template<typename _Tp>
00591     struct hash;
00592 
00593   template<>
00594     struct hash<experimental::string_view>
00595     : public __hash_base<size_t, experimental::string_view>
00596     {
00597       size_t
00598       operator()(const experimental::string_view& __str) const noexcept
00599       { return std::_Hash_impl::hash(__str.data(), __str.length()); }
00600     };
00601 
00602   template<>
00603     struct __is_fast_hash<hash<experimental::string_view>> : std::false_type
00604     { };
00605 
00606 #ifdef _GLIBCXX_USE_WCHAR_T
00607   template<>
00608     struct hash<experimental::wstring_view>
00609     : public __hash_base<size_t, wstring>
00610     {
00611       size_t
00612       operator()(const experimental::wstring_view& __s) const noexcept
00613       { return std::_Hash_impl::hash(__s.data(),
00614                                      __s.length() * sizeof(wchar_t)); }
00615     };
00616 
00617   template<>
00618     struct __is_fast_hash<hash<experimental::wstring_view>> : std::false_type
00619     { };
00620 #endif
00621 
00622 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
00623   template<>
00624     struct hash<experimental::u16string_view>
00625     : public __hash_base<size_t, experimental::u16string_view>
00626     {
00627       size_t
00628       operator()(const experimental::u16string_view& __s) const noexcept
00629       { return std::_Hash_impl::hash(__s.data(),
00630                                      __s.length() * sizeof(char16_t)); }
00631     };
00632 
00633   template<>
00634     struct __is_fast_hash<hash<experimental::u16string_view>> : std::false_type
00635     { };
00636 
00637   template<>
00638     struct hash<experimental::u32string_view>
00639     : public __hash_base<size_t, experimental::u32string_view>
00640     {
00641       size_t
00642       operator()(const experimental::u32string_view& __s) const noexcept
00643       { return std::_Hash_impl::hash(__s.data(),
00644                                      __s.length() * sizeof(char32_t)); }
00645     };
00646 
00647   template<>
00648     struct __is_fast_hash<hash<experimental::u32string_view>> : std::false_type
00649     { };
00650 #endif
00651 _GLIBCXX_END_NAMESPACE_VERSION
00652 
00653 namespace experimental
00654 {
00655   // I added these EMSR.
00656   inline namespace literals
00657   {
00658   inline namespace string_view_literals
00659   {
00660   _GLIBCXX_BEGIN_NAMESPACE_VERSION
00661 
00662     inline constexpr basic_string_view<char>
00663     operator""sv(const char* __str, size_t __len) noexcept
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) noexcept
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) noexcept
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) noexcept
00679     { return basic_string_view<char32_t>{__str, __len}; }
00680 #endif
00681 
00682   _GLIBCXX_END_NAMESPACE_VERSION
00683   } // namespace string_literals
00684   } // namespace literals
00685 } // namespace experimental
00686 } // namespace std
00687 
00688 #include <experimental/bits/string_view.tcc>
00689 
00690 #endif // __cplusplus <= 201103L
00691 
00692 #endif // _GLIBCXX_EXPERIMENTAL_STRING_VIEW