xref: /freebsd/contrib/llvm-project/libcxx/include/string_view (revision fe6060f10f634930ff71b7c50291ddc610da2475)
10b57cec5SDimitry Andric// -*- C++ -*-
20b57cec5SDimitry Andric//===------------------------ string_view ---------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_STRING_VIEW
110b57cec5SDimitry Andric#define _LIBCPP_STRING_VIEW
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andricstring_view synopsis
150b57cec5SDimitry Andric
160b57cec5SDimitry Andricnamespace std {
170b57cec5SDimitry Andric
180b57cec5SDimitry Andric    // 7.2, Class template basic_string_view
190b57cec5SDimitry Andric    template<class charT, class traits = char_traits<charT>>
200b57cec5SDimitry Andric        class basic_string_view;
210b57cec5SDimitry Andric
22*fe6060f1SDimitry Andric    template<class charT, class traits>
23*fe6060f1SDimitry Andric    inline constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true;
24*fe6060f1SDimitry Andric
25*fe6060f1SDimitry Andric    template<class charT, class traits>
26*fe6060f1SDimitry Andric    inline constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true;  // C++20
27*fe6060f1SDimitry Andric
280b57cec5SDimitry Andric    // 7.9, basic_string_view non-member comparison functions
290b57cec5SDimitry Andric    template<class charT, class traits>
300b57cec5SDimitry Andric    constexpr bool operator==(basic_string_view<charT, traits> x,
310b57cec5SDimitry Andric                              basic_string_view<charT, traits> y) noexcept;
320b57cec5SDimitry Andric    template<class charT, class traits>
330b57cec5SDimitry Andric    constexpr bool operator!=(basic_string_view<charT, traits> x,
340b57cec5SDimitry Andric                              basic_string_view<charT, traits> y) noexcept;
350b57cec5SDimitry Andric    template<class charT, class traits>
360b57cec5SDimitry Andric    constexpr bool operator< (basic_string_view<charT, traits> x,
370b57cec5SDimitry Andric                                 basic_string_view<charT, traits> y) noexcept;
380b57cec5SDimitry Andric    template<class charT, class traits>
390b57cec5SDimitry Andric    constexpr bool operator> (basic_string_view<charT, traits> x,
400b57cec5SDimitry Andric                              basic_string_view<charT, traits> y) noexcept;
410b57cec5SDimitry Andric    template<class charT, class traits>
420b57cec5SDimitry Andric    constexpr bool operator<=(basic_string_view<charT, traits> x,
430b57cec5SDimitry Andric                                 basic_string_view<charT, traits> y) noexcept;
440b57cec5SDimitry Andric    template<class charT, class traits>
450b57cec5SDimitry Andric    constexpr bool operator>=(basic_string_view<charT, traits> x,
460b57cec5SDimitry Andric                              basic_string_view<charT, traits> y) noexcept;
470b57cec5SDimitry Andric    // see below, sufficient additional overloads of comparison functions
480b57cec5SDimitry Andric
490b57cec5SDimitry Andric    // 7.10, Inserters and extractors
500b57cec5SDimitry Andric    template<class charT, class traits>
510b57cec5SDimitry Andric      basic_ostream<charT, traits>&
520b57cec5SDimitry Andric        operator<<(basic_ostream<charT, traits>& os,
530b57cec5SDimitry Andric                   basic_string_view<charT, traits> str);
540b57cec5SDimitry Andric
550b57cec5SDimitry Andric    // basic_string_view typedef names
560b57cec5SDimitry Andric    typedef basic_string_view<char> string_view;
57*fe6060f1SDimitry Andric    typedef basic_string_view<char8_t> u8string_view; // C++20
580b57cec5SDimitry Andric    typedef basic_string_view<char16_t> u16string_view;
590b57cec5SDimitry Andric    typedef basic_string_view<char32_t> u32string_view;
600b57cec5SDimitry Andric    typedef basic_string_view<wchar_t> wstring_view;
610b57cec5SDimitry Andric
620b57cec5SDimitry Andric    template<class charT, class traits = char_traits<charT>>
630b57cec5SDimitry Andric    class basic_string_view {
640b57cec5SDimitry Andric      public:
650b57cec5SDimitry Andric      // types
660b57cec5SDimitry Andric      typedef traits traits_type;
670b57cec5SDimitry Andric      typedef charT value_type;
680b57cec5SDimitry Andric      typedef charT* pointer;
690b57cec5SDimitry Andric      typedef const charT* const_pointer;
700b57cec5SDimitry Andric      typedef charT& reference;
710b57cec5SDimitry Andric      typedef const charT& const_reference;
720b57cec5SDimitry Andric      typedef implementation-defined const_iterator;
730b57cec5SDimitry Andric      typedef const_iterator iterator;
740b57cec5SDimitry Andric      typedef reverse_iterator<const_iterator> const_reverse_iterator;
750b57cec5SDimitry Andric      typedef const_reverse_iterator reverse_iterator;
760b57cec5SDimitry Andric      typedef size_t size_type;
770b57cec5SDimitry Andric      typedef ptrdiff_t difference_type;
780b57cec5SDimitry Andric      static constexpr size_type npos = size_type(-1);
790b57cec5SDimitry Andric
800b57cec5SDimitry Andric      // 7.3, basic_string_view constructors and assignment operators
810b57cec5SDimitry Andric      constexpr basic_string_view() noexcept;
820b57cec5SDimitry Andric      constexpr basic_string_view(const basic_string_view&) noexcept = default;
830b57cec5SDimitry Andric      basic_string_view& operator=(const basic_string_view&) noexcept = default;
840b57cec5SDimitry Andric      template<class Allocator>
850b57cec5SDimitry Andric      constexpr basic_string_view(const charT* str);
86*fe6060f1SDimitry Andric      basic_string_view(nullptr_t) = delete; // C++2b
870b57cec5SDimitry Andric      constexpr basic_string_view(const charT* str, size_type len);
880b57cec5SDimitry Andric
890b57cec5SDimitry Andric      // 7.4, basic_string_view iterator support
900b57cec5SDimitry Andric      constexpr const_iterator begin() const noexcept;
910b57cec5SDimitry Andric      constexpr const_iterator end() const noexcept;
920b57cec5SDimitry Andric      constexpr const_iterator cbegin() const noexcept;
930b57cec5SDimitry Andric      constexpr const_iterator cend() const noexcept;
940b57cec5SDimitry Andric      const_reverse_iterator rbegin() const noexcept;
950b57cec5SDimitry Andric      const_reverse_iterator rend() const noexcept;
960b57cec5SDimitry Andric      const_reverse_iterator crbegin() const noexcept;
970b57cec5SDimitry Andric      const_reverse_iterator crend() const noexcept;
980b57cec5SDimitry Andric
990b57cec5SDimitry Andric      // 7.5, basic_string_view capacity
1000b57cec5SDimitry Andric      constexpr size_type size() const noexcept;
1010b57cec5SDimitry Andric      constexpr size_type length() const noexcept;
1020b57cec5SDimitry Andric      constexpr size_type max_size() const noexcept;
1030b57cec5SDimitry Andric      constexpr bool empty() const noexcept;
1040b57cec5SDimitry Andric
1050b57cec5SDimitry Andric      // 7.6, basic_string_view element access
1060b57cec5SDimitry Andric      constexpr const_reference operator[](size_type pos) const;
1070b57cec5SDimitry Andric      constexpr const_reference at(size_type pos) const;
1080b57cec5SDimitry Andric      constexpr const_reference front() const;
1090b57cec5SDimitry Andric      constexpr const_reference back() const;
1100b57cec5SDimitry Andric      constexpr const_pointer data() const noexcept;
1110b57cec5SDimitry Andric
1120b57cec5SDimitry Andric      // 7.7, basic_string_view modifiers
1130b57cec5SDimitry Andric      constexpr void remove_prefix(size_type n);
1140b57cec5SDimitry Andric      constexpr void remove_suffix(size_type n);
1150b57cec5SDimitry Andric      constexpr void swap(basic_string_view& s) noexcept;
1160b57cec5SDimitry Andric
117*fe6060f1SDimitry Andric      size_type copy(charT* s, size_type n, size_type pos = 0) const;  // constexpr in C++20
1180b57cec5SDimitry Andric
1190b57cec5SDimitry Andric      constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
1200b57cec5SDimitry Andric      constexpr int compare(basic_string_view s) const noexcept;
1210b57cec5SDimitry Andric      constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
1220b57cec5SDimitry Andric      constexpr int compare(size_type pos1, size_type n1,
1230b57cec5SDimitry Andric                            basic_string_view s, size_type pos2, size_type n2) const;
1240b57cec5SDimitry Andric      constexpr int compare(const charT* s) const;
1250b57cec5SDimitry Andric      constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
1260b57cec5SDimitry Andric      constexpr int compare(size_type pos1, size_type n1,
1270b57cec5SDimitry Andric                            const charT* s, size_type n2) const;
1280b57cec5SDimitry Andric      constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
1290b57cec5SDimitry Andric      constexpr size_type find(charT c, size_type pos = 0) const noexcept;
130*fe6060f1SDimitry Andric      constexpr size_type find(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
131*fe6060f1SDimitry Andric      constexpr size_type find(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension
1320b57cec5SDimitry Andric      constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
1330b57cec5SDimitry Andric      constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
134*fe6060f1SDimitry Andric      constexpr size_type rfind(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
135*fe6060f1SDimitry Andric      constexpr size_type rfind(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension
1360b57cec5SDimitry Andric      constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
1370b57cec5SDimitry Andric      constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
138*fe6060f1SDimitry Andric      constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
139*fe6060f1SDimitry Andric      constexpr size_type find_first_of(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension
1400b57cec5SDimitry Andric      constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
1410b57cec5SDimitry Andric      constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
142*fe6060f1SDimitry Andric      constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
143*fe6060f1SDimitry Andric      constexpr size_type find_last_of(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension
1440b57cec5SDimitry Andric      constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
1450b57cec5SDimitry Andric      constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
146*fe6060f1SDimitry Andric      constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
147*fe6060f1SDimitry Andric      constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension
1480b57cec5SDimitry Andric      constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
1490b57cec5SDimitry Andric      constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
150*fe6060f1SDimitry Andric      constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
151*fe6060f1SDimitry Andric      constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension
1520b57cec5SDimitry Andric
153e8d8bef9SDimitry Andric      constexpr bool starts_with(basic_string_view s) const noexcept; // C++20
154e8d8bef9SDimitry Andric      constexpr bool starts_with(charT c) const noexcept;             // C++20
155e8d8bef9SDimitry Andric      constexpr bool starts_with(const charT* s) const;               // C++20
156e8d8bef9SDimitry Andric      constexpr bool ends_with(basic_string_view s) const noexcept;   // C++20
157e8d8bef9SDimitry Andric      constexpr bool ends_with(charT c) const noexcept;               // C++20
158e8d8bef9SDimitry Andric      constexpr bool ends_with(const charT* s) const;                 // C++20
159e8d8bef9SDimitry Andric
160e8d8bef9SDimitry Andric      constexpr bool contains(basic_string_view s) const noexcept; // C++2b
161e8d8bef9SDimitry Andric      constexpr bool contains(charT c) const noexcept;             // C++2b
162e8d8bef9SDimitry Andric      constexpr bool contains(const charT* s) const;               // C++2b
1630b57cec5SDimitry Andric
1640b57cec5SDimitry Andric     private:
1650b57cec5SDimitry Andric      const_pointer data_;  // exposition only
1660b57cec5SDimitry Andric      size_type     size_;  // exposition only
1670b57cec5SDimitry Andric    };
1680b57cec5SDimitry Andric
1690b57cec5SDimitry Andric  // 7.11, Hash support
1700b57cec5SDimitry Andric  template <class T> struct hash;
1710b57cec5SDimitry Andric  template <> struct hash<string_view>;
172*fe6060f1SDimitry Andric  template <> struct hash<u8string_view>; // C++20
1730b57cec5SDimitry Andric  template <> struct hash<u16string_view>;
1740b57cec5SDimitry Andric  template <> struct hash<u32string_view>;
1750b57cec5SDimitry Andric  template <> struct hash<wstring_view>;
1760b57cec5SDimitry Andric
1770b57cec5SDimitry Andric  constexpr basic_string_view<char>     operator "" sv( const char *str,     size_t len ) noexcept;
1780b57cec5SDimitry Andric  constexpr basic_string_view<wchar_t>  operator "" sv( const wchar_t *str,  size_t len ) noexcept;
179*fe6060f1SDimitry Andric  constexpr basic_string_view<char8_t>  operator "" sv( const char8_t *str,  size_t len ) noexcept; // C++20
1800b57cec5SDimitry Andric  constexpr basic_string_view<char16_t> operator "" sv( const char16_t *str, size_t len ) noexcept;
1810b57cec5SDimitry Andric  constexpr basic_string_view<char32_t> operator "" sv( const char32_t *str, size_t len ) noexcept;
1820b57cec5SDimitry Andric
1830b57cec5SDimitry Andric}  // namespace std
1840b57cec5SDimitry Andric
1850b57cec5SDimitry Andric
1860b57cec5SDimitry Andric*/
1870b57cec5SDimitry Andric
1880b57cec5SDimitry Andric#include <__config>
189*fe6060f1SDimitry Andric#include <__debug>
190*fe6060f1SDimitry Andric#include <__ranges/enable_borrowed_range.h>
191*fe6060f1SDimitry Andric#include <__ranges/enable_view.h>
1920b57cec5SDimitry Andric#include <__string>
1930b57cec5SDimitry Andric#include <algorithm>
194*fe6060f1SDimitry Andric#include <compare>
195*fe6060f1SDimitry Andric#include <iosfwd>
1960b57cec5SDimitry Andric#include <iterator>
1970b57cec5SDimitry Andric#include <limits>
1980b57cec5SDimitry Andric#include <stdexcept>
1990b57cec5SDimitry Andric#include <version>
2000b57cec5SDimitry Andric
2010b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2020b57cec5SDimitry Andric#pragma GCC system_header
2030b57cec5SDimitry Andric#endif
2040b57cec5SDimitry Andric
2050b57cec5SDimitry Andric_LIBCPP_PUSH_MACROS
2060b57cec5SDimitry Andric#include <__undef_macros>
2070b57cec5SDimitry Andric
2080b57cec5SDimitry Andric
2090b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
2100b57cec5SDimitry Andric
2110b57cec5SDimitry Andrictemplate<class _CharT, class _Traits = char_traits<_CharT> >
212e8d8bef9SDimitry Andric    class _LIBCPP_TEMPLATE_VIS basic_string_view;
213e8d8bef9SDimitry Andric
214e8d8bef9SDimitry Andrictypedef basic_string_view<char>     string_view;
215*fe6060f1SDimitry Andric#ifndef _LIBCPP_HAS_NO_CHAR8_T
216e8d8bef9SDimitry Andrictypedef basic_string_view<char8_t>  u8string_view;
217e8d8bef9SDimitry Andric#endif
218e8d8bef9SDimitry Andrictypedef basic_string_view<char16_t> u16string_view;
219e8d8bef9SDimitry Andrictypedef basic_string_view<char32_t> u32string_view;
220e8d8bef9SDimitry Andrictypedef basic_string_view<wchar_t>  wstring_view;
221e8d8bef9SDimitry Andric
222e8d8bef9SDimitry Andrictemplate<class _CharT, class _Traits>
223e8d8bef9SDimitry Andricclass
224e8d8bef9SDimitry Andric    _LIBCPP_PREFERRED_NAME(string_view)
225*fe6060f1SDimitry Andric#ifndef _LIBCPP_HAS_NO_CHAR8_T
226e8d8bef9SDimitry Andric    _LIBCPP_PREFERRED_NAME(u8string_view)
227e8d8bef9SDimitry Andric#endif
228e8d8bef9SDimitry Andric    _LIBCPP_PREFERRED_NAME(u16string_view)
229e8d8bef9SDimitry Andric    _LIBCPP_PREFERRED_NAME(u32string_view)
230e8d8bef9SDimitry Andric    _LIBCPP_PREFERRED_NAME(wstring_view)
231e8d8bef9SDimitry Andric    basic_string_view {
2320b57cec5SDimitry Andricpublic:
2330b57cec5SDimitry Andric    // types
2340b57cec5SDimitry Andric    typedef _Traits                                    traits_type;
2350b57cec5SDimitry Andric    typedef _CharT                                     value_type;
2360b57cec5SDimitry Andric    typedef _CharT*                                    pointer;
2370b57cec5SDimitry Andric    typedef const _CharT*                              const_pointer;
2380b57cec5SDimitry Andric    typedef _CharT&                                    reference;
2390b57cec5SDimitry Andric    typedef const _CharT&                              const_reference;
2400b57cec5SDimitry Andric    typedef const_pointer                              const_iterator; // See [string.view.iterators]
2410b57cec5SDimitry Andric    typedef const_iterator                             iterator;
2420b57cec5SDimitry Andric    typedef _VSTD::reverse_iterator<const_iterator>    const_reverse_iterator;
2430b57cec5SDimitry Andric    typedef const_reverse_iterator                     reverse_iterator;
2440b57cec5SDimitry Andric    typedef size_t                                     size_type;
2450b57cec5SDimitry Andric    typedef ptrdiff_t                                  difference_type;
2460b57cec5SDimitry Andric    static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
2470b57cec5SDimitry Andric
2480b57cec5SDimitry Andric    static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array");
2490b57cec5SDimitry Andric    static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string_view must be standard-layout");
2500b57cec5SDimitry Andric    static_assert(( is_trivial<value_type>::value), "Character type of basic_string_view must be trivial");
2510b57cec5SDimitry Andric    static_assert((is_same<_CharT, typename traits_type::char_type>::value),
2520b57cec5SDimitry Andric                  "traits_type::char_type must be the same type as CharT");
2530b57cec5SDimitry Andric
2540b57cec5SDimitry Andric    // [string.view.cons], construct/copy
2550b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
2560b57cec5SDimitry Andric    basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
2570b57cec5SDimitry Andric
2580b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
2590b57cec5SDimitry Andric    basic_string_view(const basic_string_view&) _NOEXCEPT = default;
2600b57cec5SDimitry Andric
2610b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
2620b57cec5SDimitry Andric    basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
2630b57cec5SDimitry Andric
2640b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
2650b57cec5SDimitry Andric    basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
2660b57cec5SDimitry Andric        : __data(__s), __size(__len)
2670b57cec5SDimitry Andric    {
2680b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
2690b57cec5SDimitry Andric    _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
2700b57cec5SDimitry Andric#endif
2710b57cec5SDimitry Andric    }
2720b57cec5SDimitry Andric
2730b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
2740b57cec5SDimitry Andric    basic_string_view(const _CharT* __s)
275e8d8bef9SDimitry Andric        : __data(__s), __size(_VSTD::__char_traits_length_checked<_Traits>(__s)) {}
2760b57cec5SDimitry Andric
277*fe6060f1SDimitry Andric#if _LIBCPP_STD_VER > 20
278*fe6060f1SDimitry Andric    basic_string_view(nullptr_t) = delete;
279*fe6060f1SDimitry Andric#endif
280*fe6060f1SDimitry Andric
2810b57cec5SDimitry Andric    // [string.view.iterators], iterators
2820b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
2830b57cec5SDimitry Andric    const_iterator begin()  const _NOEXCEPT { return cbegin(); }
2840b57cec5SDimitry Andric
2850b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
2860b57cec5SDimitry Andric    const_iterator end()    const _NOEXCEPT { return cend(); }
2870b57cec5SDimitry Andric
2880b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
2890b57cec5SDimitry Andric    const_iterator cbegin() const _NOEXCEPT { return __data; }
2900b57cec5SDimitry Andric
2910b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
2920b57cec5SDimitry Andric    const_iterator cend()   const _NOEXCEPT { return __data + __size; }
2930b57cec5SDimitry Andric
2940b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
2950b57cec5SDimitry Andric    const_reverse_iterator rbegin()   const _NOEXCEPT { return const_reverse_iterator(cend()); }
2960b57cec5SDimitry Andric
2970b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
2980b57cec5SDimitry Andric    const_reverse_iterator rend()     const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
2990b57cec5SDimitry Andric
3000b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
3010b57cec5SDimitry Andric    const_reverse_iterator crbegin()  const _NOEXCEPT { return const_reverse_iterator(cend()); }
3020b57cec5SDimitry Andric
3030b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
3040b57cec5SDimitry Andric    const_reverse_iterator crend()    const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
3050b57cec5SDimitry Andric
3060b57cec5SDimitry Andric    // [string.view.capacity], capacity
3070b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3080b57cec5SDimitry Andric    size_type size()     const _NOEXCEPT { return __size; }
3090b57cec5SDimitry Andric
3100b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3110b57cec5SDimitry Andric    size_type length()   const _NOEXCEPT { return __size; }
3120b57cec5SDimitry Andric
3130b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3140b57cec5SDimitry Andric    size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max(); }
3150b57cec5SDimitry Andric
3160b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
3170b57cec5SDimitry Andric    bool empty()         const _NOEXCEPT { return __size == 0; }
3180b57cec5SDimitry Andric
3190b57cec5SDimitry Andric    // [string.view.access], element access
3200b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
321e8d8bef9SDimitry Andric    const_reference operator[](size_type __pos) const _NOEXCEPT {
322e8d8bef9SDimitry Andric      return _LIBCPP_ASSERT(__pos < size(), "string_view[] index out of bounds"), __data[__pos];
323e8d8bef9SDimitry Andric    }
3240b57cec5SDimitry Andric
3250b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3260b57cec5SDimitry Andric    const_reference at(size_type __pos) const
3270b57cec5SDimitry Andric    {
3280b57cec5SDimitry Andric        return __pos >= size()
3290b57cec5SDimitry Andric            ? (__throw_out_of_range("string_view::at"), __data[0])
3300b57cec5SDimitry Andric            : __data[__pos];
3310b57cec5SDimitry Andric    }
3320b57cec5SDimitry Andric
3330b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3340b57cec5SDimitry Andric    const_reference front() const _NOEXCEPT
3350b57cec5SDimitry Andric    {
3360b57cec5SDimitry Andric        return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
3370b57cec5SDimitry Andric    }
3380b57cec5SDimitry Andric
3390b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3400b57cec5SDimitry Andric    const_reference back() const _NOEXCEPT
3410b57cec5SDimitry Andric    {
3420b57cec5SDimitry Andric        return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
3430b57cec5SDimitry Andric    }
3440b57cec5SDimitry Andric
3450b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3460b57cec5SDimitry Andric    const_pointer data() const _NOEXCEPT { return __data; }
3470b57cec5SDimitry Andric
3480b57cec5SDimitry Andric    // [string.view.modifiers], modifiers:
3490b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
3500b57cec5SDimitry Andric    void remove_prefix(size_type __n) _NOEXCEPT
3510b57cec5SDimitry Andric    {
3520b57cec5SDimitry Andric        _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
3530b57cec5SDimitry Andric        __data += __n;
3540b57cec5SDimitry Andric        __size -= __n;
3550b57cec5SDimitry Andric    }
3560b57cec5SDimitry Andric
3570b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
3580b57cec5SDimitry Andric    void remove_suffix(size_type __n) _NOEXCEPT
3590b57cec5SDimitry Andric    {
3600b57cec5SDimitry Andric        _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
3610b57cec5SDimitry Andric        __size -= __n;
3620b57cec5SDimitry Andric    }
3630b57cec5SDimitry Andric
3640b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
3650b57cec5SDimitry Andric    void swap(basic_string_view& __other) _NOEXCEPT
3660b57cec5SDimitry Andric    {
3670b57cec5SDimitry Andric        const value_type *__p = __data;
3680b57cec5SDimitry Andric        __data = __other.__data;
3690b57cec5SDimitry Andric        __other.__data = __p;
3700b57cec5SDimitry Andric
3710b57cec5SDimitry Andric        size_type __sz = __size;
3720b57cec5SDimitry Andric        __size = __other.__size;
3730b57cec5SDimitry Andric        __other.__size = __sz;
3740b57cec5SDimitry Andric    }
3750b57cec5SDimitry Andric
376*fe6060f1SDimitry Andric    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
3770b57cec5SDimitry Andric    size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
3780b57cec5SDimitry Andric    {
3790b57cec5SDimitry Andric        if (__pos > size())
3800b57cec5SDimitry Andric            __throw_out_of_range("string_view::copy");
3810b57cec5SDimitry Andric        size_type __rlen = _VSTD::min(__n, size() - __pos);
3820b57cec5SDimitry Andric        _Traits::copy(__s, data() + __pos, __rlen);
3830b57cec5SDimitry Andric        return __rlen;
3840b57cec5SDimitry Andric    }
3850b57cec5SDimitry Andric
3860b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3870b57cec5SDimitry Andric    basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
3880b57cec5SDimitry Andric    {
3890b57cec5SDimitry Andric        return __pos > size()
3900b57cec5SDimitry Andric            ? (__throw_out_of_range("string_view::substr"), basic_string_view())
3910b57cec5SDimitry Andric            : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
3920b57cec5SDimitry Andric    }
3930b57cec5SDimitry Andric
3940b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
3950b57cec5SDimitry Andric    {
3960b57cec5SDimitry Andric        size_type __rlen = _VSTD::min( size(), __sv.size());
3970b57cec5SDimitry Andric        int __retval = _Traits::compare(data(), __sv.data(), __rlen);
3980b57cec5SDimitry Andric        if ( __retval == 0 ) // first __rlen chars matched
3990b57cec5SDimitry Andric            __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
4000b57cec5SDimitry Andric        return __retval;
4010b57cec5SDimitry Andric    }
4020b57cec5SDimitry Andric
4030b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
4040b57cec5SDimitry Andric    int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
4050b57cec5SDimitry Andric    {
4060b57cec5SDimitry Andric        return substr(__pos1, __n1).compare(__sv);
4070b57cec5SDimitry Andric    }
4080b57cec5SDimitry Andric
4090b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
4100b57cec5SDimitry Andric    int compare(                       size_type __pos1, size_type __n1,
4110b57cec5SDimitry Andric                basic_string_view __sv, size_type __pos2, size_type __n2) const
4120b57cec5SDimitry Andric    {
4130b57cec5SDimitry Andric        return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
4140b57cec5SDimitry Andric    }
4150b57cec5SDimitry Andric
4160b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
4170b57cec5SDimitry Andric    int compare(const _CharT* __s) const _NOEXCEPT
4180b57cec5SDimitry Andric    {
4190b57cec5SDimitry Andric        return compare(basic_string_view(__s));
4200b57cec5SDimitry Andric    }
4210b57cec5SDimitry Andric
4220b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
4230b57cec5SDimitry Andric    int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
4240b57cec5SDimitry Andric    {
4250b57cec5SDimitry Andric        return substr(__pos1, __n1).compare(basic_string_view(__s));
4260b57cec5SDimitry Andric    }
4270b57cec5SDimitry Andric
4280b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
4290b57cec5SDimitry Andric    int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
4300b57cec5SDimitry Andric    {
4310b57cec5SDimitry Andric        return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
4320b57cec5SDimitry Andric    }
4330b57cec5SDimitry Andric
4340b57cec5SDimitry Andric    // find
4350b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
4360b57cec5SDimitry Andric    size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
4370b57cec5SDimitry Andric    {
4380b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
4390b57cec5SDimitry Andric        return __str_find<value_type, size_type, traits_type, npos>
4400b57cec5SDimitry Andric            (data(), size(), __s.data(), __pos, __s.size());
4410b57cec5SDimitry Andric    }
4420b57cec5SDimitry Andric
4430b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
4440b57cec5SDimitry Andric    size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
4450b57cec5SDimitry Andric    {
4460b57cec5SDimitry Andric        return __str_find<value_type, size_type, traits_type, npos>
4470b57cec5SDimitry Andric            (data(), size(), __c, __pos);
4480b57cec5SDimitry Andric    }
4490b57cec5SDimitry Andric
4500b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
451*fe6060f1SDimitry Andric    size_type find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
4520b57cec5SDimitry Andric    {
4530b57cec5SDimitry Andric        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
4540b57cec5SDimitry Andric        return __str_find<value_type, size_type, traits_type, npos>
4550b57cec5SDimitry Andric            (data(), size(), __s, __pos, __n);
4560b57cec5SDimitry Andric    }
4570b57cec5SDimitry Andric
4580b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
459*fe6060f1SDimitry Andric    size_type find(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT
4600b57cec5SDimitry Andric    {
4610b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");
4620b57cec5SDimitry Andric        return __str_find<value_type, size_type, traits_type, npos>
4630b57cec5SDimitry Andric            (data(), size(), __s, __pos, traits_type::length(__s));
4640b57cec5SDimitry Andric    }
4650b57cec5SDimitry Andric
4660b57cec5SDimitry Andric    // rfind
4670b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
4680b57cec5SDimitry Andric    size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
4690b57cec5SDimitry Andric    {
4700b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
4710b57cec5SDimitry Andric        return __str_rfind<value_type, size_type, traits_type, npos>
4720b57cec5SDimitry Andric            (data(), size(), __s.data(), __pos, __s.size());
4730b57cec5SDimitry Andric    }
4740b57cec5SDimitry Andric
4750b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
4760b57cec5SDimitry Andric    size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
4770b57cec5SDimitry Andric    {
4780b57cec5SDimitry Andric        return __str_rfind<value_type, size_type, traits_type, npos>
4790b57cec5SDimitry Andric            (data(), size(), __c, __pos);
4800b57cec5SDimitry Andric    }
4810b57cec5SDimitry Andric
4820b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
483*fe6060f1SDimitry Andric    size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
4840b57cec5SDimitry Andric    {
4850b57cec5SDimitry Andric        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
4860b57cec5SDimitry Andric        return __str_rfind<value_type, size_type, traits_type, npos>
4870b57cec5SDimitry Andric            (data(), size(), __s, __pos, __n);
4880b57cec5SDimitry Andric    }
4890b57cec5SDimitry Andric
4900b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
491*fe6060f1SDimitry Andric    size_type rfind(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
4920b57cec5SDimitry Andric    {
4930b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");
4940b57cec5SDimitry Andric        return __str_rfind<value_type, size_type, traits_type, npos>
4950b57cec5SDimitry Andric            (data(), size(), __s, __pos, traits_type::length(__s));
4960b57cec5SDimitry Andric    }
4970b57cec5SDimitry Andric
4980b57cec5SDimitry Andric    // find_first_of
4990b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5000b57cec5SDimitry Andric    size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
5010b57cec5SDimitry Andric    {
5020b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
5030b57cec5SDimitry Andric        return __str_find_first_of<value_type, size_type, traits_type, npos>
5040b57cec5SDimitry Andric            (data(), size(), __s.data(), __pos, __s.size());
5050b57cec5SDimitry Andric    }
5060b57cec5SDimitry Andric
5070b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5080b57cec5SDimitry Andric    size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
5090b57cec5SDimitry Andric    { return find(__c, __pos); }
5100b57cec5SDimitry Andric
5110b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
512*fe6060f1SDimitry Andric    size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
5130b57cec5SDimitry Andric    {
5140b57cec5SDimitry Andric        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
5150b57cec5SDimitry Andric        return __str_find_first_of<value_type, size_type, traits_type, npos>
5160b57cec5SDimitry Andric            (data(), size(), __s, __pos, __n);
5170b57cec5SDimitry Andric    }
5180b57cec5SDimitry Andric
5190b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
520*fe6060f1SDimitry Andric    size_type find_first_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT
5210b57cec5SDimitry Andric    {
5220b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");
5230b57cec5SDimitry Andric        return __str_find_first_of<value_type, size_type, traits_type, npos>
5240b57cec5SDimitry Andric            (data(), size(), __s, __pos, traits_type::length(__s));
5250b57cec5SDimitry Andric    }
5260b57cec5SDimitry Andric
5270b57cec5SDimitry Andric    // find_last_of
5280b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5290b57cec5SDimitry Andric    size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
5300b57cec5SDimitry Andric    {
5310b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
5320b57cec5SDimitry Andric        return __str_find_last_of<value_type, size_type, traits_type, npos>
5330b57cec5SDimitry Andric            (data(), size(), __s.data(), __pos, __s.size());
5340b57cec5SDimitry Andric    }
5350b57cec5SDimitry Andric
5360b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5370b57cec5SDimitry Andric    size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
5380b57cec5SDimitry Andric    { return rfind(__c, __pos); }
5390b57cec5SDimitry Andric
5400b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
541*fe6060f1SDimitry Andric    size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
5420b57cec5SDimitry Andric    {
5430b57cec5SDimitry Andric        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
5440b57cec5SDimitry Andric        return __str_find_last_of<value_type, size_type, traits_type, npos>
5450b57cec5SDimitry Andric            (data(), size(), __s, __pos, __n);
5460b57cec5SDimitry Andric    }
5470b57cec5SDimitry Andric
5480b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
549*fe6060f1SDimitry Andric    size_type find_last_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
5500b57cec5SDimitry Andric    {
5510b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");
5520b57cec5SDimitry Andric        return __str_find_last_of<value_type, size_type, traits_type, npos>
5530b57cec5SDimitry Andric            (data(), size(), __s, __pos, traits_type::length(__s));
5540b57cec5SDimitry Andric    }
5550b57cec5SDimitry Andric
5560b57cec5SDimitry Andric    // find_first_not_of
5570b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5580b57cec5SDimitry Andric    size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
5590b57cec5SDimitry Andric    {
5600b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
5610b57cec5SDimitry Andric        return __str_find_first_not_of<value_type, size_type, traits_type, npos>
5620b57cec5SDimitry Andric            (data(), size(), __s.data(), __pos, __s.size());
5630b57cec5SDimitry Andric    }
5640b57cec5SDimitry Andric
5650b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5660b57cec5SDimitry Andric    size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
5670b57cec5SDimitry Andric    {
5680b57cec5SDimitry Andric        return __str_find_first_not_of<value_type, size_type, traits_type, npos>
5690b57cec5SDimitry Andric            (data(), size(), __c, __pos);
5700b57cec5SDimitry Andric    }
5710b57cec5SDimitry Andric
5720b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
573*fe6060f1SDimitry Andric    size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
5740b57cec5SDimitry Andric    {
5750b57cec5SDimitry Andric        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
5760b57cec5SDimitry Andric        return __str_find_first_not_of<value_type, size_type, traits_type, npos>
5770b57cec5SDimitry Andric            (data(), size(), __s, __pos, __n);
5780b57cec5SDimitry Andric    }
5790b57cec5SDimitry Andric
5800b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
581*fe6060f1SDimitry Andric    size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT
5820b57cec5SDimitry Andric    {
5830b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
5840b57cec5SDimitry Andric        return __str_find_first_not_of<value_type, size_type, traits_type, npos>
5850b57cec5SDimitry Andric            (data(), size(), __s, __pos, traits_type::length(__s));
5860b57cec5SDimitry Andric    }
5870b57cec5SDimitry Andric
5880b57cec5SDimitry Andric    // find_last_not_of
5890b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5900b57cec5SDimitry Andric    size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
5910b57cec5SDimitry Andric    {
5920b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
5930b57cec5SDimitry Andric        return __str_find_last_not_of<value_type, size_type, traits_type, npos>
5940b57cec5SDimitry Andric            (data(), size(), __s.data(), __pos, __s.size());
5950b57cec5SDimitry Andric    }
5960b57cec5SDimitry Andric
5970b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
5980b57cec5SDimitry Andric    size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
5990b57cec5SDimitry Andric    {
6000b57cec5SDimitry Andric        return __str_find_last_not_of<value_type, size_type, traits_type, npos>
6010b57cec5SDimitry Andric            (data(), size(), __c, __pos);
6020b57cec5SDimitry Andric    }
6030b57cec5SDimitry Andric
6040b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
605*fe6060f1SDimitry Andric    size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
6060b57cec5SDimitry Andric    {
6070b57cec5SDimitry Andric        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
6080b57cec5SDimitry Andric        return __str_find_last_not_of<value_type, size_type, traits_type, npos>
6090b57cec5SDimitry Andric            (data(), size(), __s, __pos, __n);
6100b57cec5SDimitry Andric    }
6110b57cec5SDimitry Andric
6120b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
613*fe6060f1SDimitry Andric    size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
6140b57cec5SDimitry Andric    {
6150b57cec5SDimitry Andric        _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
6160b57cec5SDimitry Andric        return __str_find_last_not_of<value_type, size_type, traits_type, npos>
6170b57cec5SDimitry Andric            (data(), size(), __s, __pos, traits_type::length(__s));
6180b57cec5SDimitry Andric    }
6190b57cec5SDimitry Andric
6200b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17
6210b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6220b57cec5SDimitry Andric    bool starts_with(basic_string_view __s) const _NOEXCEPT
6230b57cec5SDimitry Andric    { return size() >= __s.size() && compare(0, __s.size(), __s) == 0; }
6240b57cec5SDimitry Andric
6250b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6260b57cec5SDimitry Andric    bool starts_with(value_type __c) const _NOEXCEPT
6270b57cec5SDimitry Andric    { return !empty() && _Traits::eq(front(), __c); }
6280b57cec5SDimitry Andric
6290b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6300b57cec5SDimitry Andric    bool starts_with(const value_type* __s) const _NOEXCEPT
6310b57cec5SDimitry Andric    { return starts_with(basic_string_view(__s)); }
6320b57cec5SDimitry Andric
6330b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6340b57cec5SDimitry Andric    bool ends_with(basic_string_view __s) const _NOEXCEPT
6350b57cec5SDimitry Andric    { return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; }
6360b57cec5SDimitry Andric
6370b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6380b57cec5SDimitry Andric    bool ends_with(value_type __c) const _NOEXCEPT
6390b57cec5SDimitry Andric    { return !empty() && _Traits::eq(back(), __c); }
6400b57cec5SDimitry Andric
6410b57cec5SDimitry Andric    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6420b57cec5SDimitry Andric    bool ends_with(const value_type* __s) const _NOEXCEPT
6430b57cec5SDimitry Andric    { return ends_with(basic_string_view(__s)); }
6440b57cec5SDimitry Andric#endif
6450b57cec5SDimitry Andric
646e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 20
647e8d8bef9SDimitry Andric    constexpr _LIBCPP_INLINE_VISIBILITY
648e8d8bef9SDimitry Andric    bool contains(basic_string_view __sv) const noexcept
649e8d8bef9SDimitry Andric    { return find(__sv) != npos; }
650e8d8bef9SDimitry Andric
651e8d8bef9SDimitry Andric    constexpr _LIBCPP_INLINE_VISIBILITY
652e8d8bef9SDimitry Andric    bool contains(value_type __c) const noexcept
653e8d8bef9SDimitry Andric    { return find(__c) != npos; }
654e8d8bef9SDimitry Andric
655e8d8bef9SDimitry Andric    constexpr _LIBCPP_INLINE_VISIBILITY
656e8d8bef9SDimitry Andric    bool contains(const value_type* __s) const
657e8d8bef9SDimitry Andric    { return find(__s) != npos; }
658e8d8bef9SDimitry Andric#endif
659e8d8bef9SDimitry Andric
6600b57cec5SDimitry Andricprivate:
6610b57cec5SDimitry Andric    const   value_type* __data;
6620b57cec5SDimitry Andric    size_type           __size;
6630b57cec5SDimitry Andric};
6640b57cec5SDimitry Andric
665*fe6060f1SDimitry Andric#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
666*fe6060f1SDimitry Andrictemplate <class _CharT, class _Traits>
667*fe6060f1SDimitry Andricinline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true;
668*fe6060f1SDimitry Andric
669*fe6060f1SDimitry Andrictemplate <class _CharT, class _Traits>
670*fe6060f1SDimitry Andricinline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;
671*fe6060f1SDimitry Andric#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
6720b57cec5SDimitry Andric
6730b57cec5SDimitry Andric// [string.view.comparison]
6740b57cec5SDimitry Andric// operator ==
6750b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
6760b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6770b57cec5SDimitry Andricbool operator==(basic_string_view<_CharT, _Traits> __lhs,
6780b57cec5SDimitry Andric                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
6790b57cec5SDimitry Andric{
6800b57cec5SDimitry Andric    if ( __lhs.size() != __rhs.size()) return false;
6810b57cec5SDimitry Andric    return __lhs.compare(__rhs) == 0;
6820b57cec5SDimitry Andric}
6830b57cec5SDimitry Andric
6840b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
6850b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6860b57cec5SDimitry Andricbool operator==(basic_string_view<_CharT, _Traits> __lhs,
6870b57cec5SDimitry Andric                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
6880b57cec5SDimitry Andric{
6890b57cec5SDimitry Andric    if ( __lhs.size() != __rhs.size()) return false;
6900b57cec5SDimitry Andric    return __lhs.compare(__rhs) == 0;
6910b57cec5SDimitry Andric}
6920b57cec5SDimitry Andric
6930b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
6940b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
6950b57cec5SDimitry Andricbool operator==(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
6960b57cec5SDimitry Andric                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
6970b57cec5SDimitry Andric{
6980b57cec5SDimitry Andric    if ( __lhs.size() != __rhs.size()) return false;
6990b57cec5SDimitry Andric    return __lhs.compare(__rhs) == 0;
7000b57cec5SDimitry Andric}
7010b57cec5SDimitry Andric
7020b57cec5SDimitry Andric
7030b57cec5SDimitry Andric// operator !=
7040b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7050b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7060b57cec5SDimitry Andricbool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
7070b57cec5SDimitry Andric{
7080b57cec5SDimitry Andric    if ( __lhs.size() != __rhs.size())
7090b57cec5SDimitry Andric        return true;
7100b57cec5SDimitry Andric    return __lhs.compare(__rhs) != 0;
7110b57cec5SDimitry Andric}
7120b57cec5SDimitry Andric
7130b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7140b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7150b57cec5SDimitry Andricbool operator!=(basic_string_view<_CharT, _Traits> __lhs,
7160b57cec5SDimitry Andric                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
7170b57cec5SDimitry Andric{
7180b57cec5SDimitry Andric    if ( __lhs.size() != __rhs.size())
7190b57cec5SDimitry Andric        return true;
7200b57cec5SDimitry Andric    return __lhs.compare(__rhs) != 0;
7210b57cec5SDimitry Andric}
7220b57cec5SDimitry Andric
7230b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7240b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7250b57cec5SDimitry Andricbool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
7260b57cec5SDimitry Andric                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
7270b57cec5SDimitry Andric{
7280b57cec5SDimitry Andric    if ( __lhs.size() != __rhs.size())
7290b57cec5SDimitry Andric        return true;
7300b57cec5SDimitry Andric    return __lhs.compare(__rhs) != 0;
7310b57cec5SDimitry Andric}
7320b57cec5SDimitry Andric
7330b57cec5SDimitry Andric
7340b57cec5SDimitry Andric// operator <
7350b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7360b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7370b57cec5SDimitry Andricbool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
7380b57cec5SDimitry Andric{
7390b57cec5SDimitry Andric    return __lhs.compare(__rhs) < 0;
7400b57cec5SDimitry Andric}
7410b57cec5SDimitry Andric
7420b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7430b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7440b57cec5SDimitry Andricbool operator<(basic_string_view<_CharT, _Traits> __lhs,
7450b57cec5SDimitry Andric                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
7460b57cec5SDimitry Andric{
7470b57cec5SDimitry Andric    return __lhs.compare(__rhs) < 0;
7480b57cec5SDimitry Andric}
7490b57cec5SDimitry Andric
7500b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7510b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7520b57cec5SDimitry Andricbool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
7530b57cec5SDimitry Andric                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
7540b57cec5SDimitry Andric{
7550b57cec5SDimitry Andric    return __lhs.compare(__rhs) < 0;
7560b57cec5SDimitry Andric}
7570b57cec5SDimitry Andric
7580b57cec5SDimitry Andric
7590b57cec5SDimitry Andric// operator >
7600b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7610b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7620b57cec5SDimitry Andricbool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
7630b57cec5SDimitry Andric{
7640b57cec5SDimitry Andric    return __lhs.compare(__rhs) > 0;
7650b57cec5SDimitry Andric}
7660b57cec5SDimitry Andric
7670b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7680b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7690b57cec5SDimitry Andricbool operator>(basic_string_view<_CharT, _Traits> __lhs,
7700b57cec5SDimitry Andric                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
7710b57cec5SDimitry Andric{
7720b57cec5SDimitry Andric    return __lhs.compare(__rhs) > 0;
7730b57cec5SDimitry Andric}
7740b57cec5SDimitry Andric
7750b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7760b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7770b57cec5SDimitry Andricbool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
7780b57cec5SDimitry Andric                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
7790b57cec5SDimitry Andric{
7800b57cec5SDimitry Andric    return __lhs.compare(__rhs) > 0;
7810b57cec5SDimitry Andric}
7820b57cec5SDimitry Andric
7830b57cec5SDimitry Andric
7840b57cec5SDimitry Andric// operator <=
7850b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7860b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7870b57cec5SDimitry Andricbool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
7880b57cec5SDimitry Andric{
7890b57cec5SDimitry Andric    return __lhs.compare(__rhs) <= 0;
7900b57cec5SDimitry Andric}
7910b57cec5SDimitry Andric
7920b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
7930b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
7940b57cec5SDimitry Andricbool operator<=(basic_string_view<_CharT, _Traits> __lhs,
7950b57cec5SDimitry Andric                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
7960b57cec5SDimitry Andric{
7970b57cec5SDimitry Andric    return __lhs.compare(__rhs) <= 0;
7980b57cec5SDimitry Andric}
7990b57cec5SDimitry Andric
8000b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
8010b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8020b57cec5SDimitry Andricbool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
8030b57cec5SDimitry Andric                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
8040b57cec5SDimitry Andric{
8050b57cec5SDimitry Andric    return __lhs.compare(__rhs) <= 0;
8060b57cec5SDimitry Andric}
8070b57cec5SDimitry Andric
8080b57cec5SDimitry Andric
8090b57cec5SDimitry Andric// operator >=
8100b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
8110b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8120b57cec5SDimitry Andricbool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
8130b57cec5SDimitry Andric{
8140b57cec5SDimitry Andric    return __lhs.compare(__rhs) >= 0;
8150b57cec5SDimitry Andric}
8160b57cec5SDimitry Andric
8170b57cec5SDimitry Andric
8180b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
8190b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8200b57cec5SDimitry Andricbool operator>=(basic_string_view<_CharT, _Traits> __lhs,
8210b57cec5SDimitry Andric                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
8220b57cec5SDimitry Andric{
8230b57cec5SDimitry Andric    return __lhs.compare(__rhs) >= 0;
8240b57cec5SDimitry Andric}
8250b57cec5SDimitry Andric
8260b57cec5SDimitry Andrictemplate<class _CharT, class _Traits>
8270b57cec5SDimitry Andric_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
8280b57cec5SDimitry Andricbool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
8290b57cec5SDimitry Andric                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
8300b57cec5SDimitry Andric{
8310b57cec5SDimitry Andric    return __lhs.compare(__rhs) >= 0;
8320b57cec5SDimitry Andric}
8330b57cec5SDimitry Andric
834e40139ffSDimitry Andric
835e40139ffSDimitry Andrictemplate<class _CharT, class _Traits>
836e40139ffSDimitry Andricbasic_ostream<_CharT, _Traits>&
837e40139ffSDimitry Andricoperator<<(basic_ostream<_CharT, _Traits>& __os,
838e40139ffSDimitry Andric           basic_string_view<_CharT, _Traits> __str);
839e40139ffSDimitry Andric
8400b57cec5SDimitry Andric// [string.view.hash]
8410b57cec5SDimitry Andrictemplate<class _CharT>
8420b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >
8430b57cec5SDimitry Andric    : public unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
8440b57cec5SDimitry Andric{
8450b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
8460b57cec5SDimitry Andric    size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {
8470b57cec5SDimitry Andric        return __do_string_hash(__val.data(), __val.data() + __val.size());
8480b57cec5SDimitry Andric    }
8490b57cec5SDimitry Andric};
8500b57cec5SDimitry Andric
8510b57cec5SDimitry Andric
8520b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11
8530b57cec5SDimitry Andricinline namespace literals
8540b57cec5SDimitry Andric{
8550b57cec5SDimitry Andric  inline namespace string_view_literals
8560b57cec5SDimitry Andric  {
8570b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
8580b57cec5SDimitry Andric    basic_string_view<char> operator "" sv(const char *__str, size_t __len) _NOEXCEPT
8590b57cec5SDimitry Andric    {
8600b57cec5SDimitry Andric        return basic_string_view<char> (__str, __len);
8610b57cec5SDimitry Andric    }
8620b57cec5SDimitry Andric
8630b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
8640b57cec5SDimitry Andric    basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len) _NOEXCEPT
8650b57cec5SDimitry Andric    {
8660b57cec5SDimitry Andric        return basic_string_view<wchar_t> (__str, __len);
8670b57cec5SDimitry Andric    }
8680b57cec5SDimitry Andric
869*fe6060f1SDimitry Andric#ifndef _LIBCPP_HAS_NO_CHAR8_T
8700b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
8710b57cec5SDimitry Andric    basic_string_view<char8_t> operator "" sv(const char8_t *__str, size_t __len) _NOEXCEPT
8720b57cec5SDimitry Andric    {
8730b57cec5SDimitry Andric        return basic_string_view<char8_t> (__str, __len);
8740b57cec5SDimitry Andric    }
8750b57cec5SDimitry Andric#endif
8760b57cec5SDimitry Andric
8770b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
8780b57cec5SDimitry Andric    basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT
8790b57cec5SDimitry Andric    {
8800b57cec5SDimitry Andric        return basic_string_view<char16_t> (__str, __len);
8810b57cec5SDimitry Andric    }
8820b57cec5SDimitry Andric
8830b57cec5SDimitry Andric    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
8840b57cec5SDimitry Andric    basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len) _NOEXCEPT
8850b57cec5SDimitry Andric    {
8860b57cec5SDimitry Andric        return basic_string_view<char32_t> (__str, __len);
8870b57cec5SDimitry Andric    }
8880b57cec5SDimitry Andric  }
8890b57cec5SDimitry Andric}
8900b57cec5SDimitry Andric#endif
8910b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
8920b57cec5SDimitry Andric
8930b57cec5SDimitry Andric_LIBCPP_POP_MACROS
8940b57cec5SDimitry Andric
8950b57cec5SDimitry Andric#endif // _LIBCPP_STRING_VIEW
896