1053d81ceSMarshall Clow// -*- C++ -*-
2*eb8650a7SLouis Dionne//===----------------------------------------------------------------------===//
3053d81ceSMarshall Clow//
42946cd70SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
52946cd70SChandler Carruth// See https://llvm.org/LICENSE.txt for license information.
62946cd70SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7053d81ceSMarshall Clow//
8053d81ceSMarshall Clow//===----------------------------------------------------------------------===//
9053d81ceSMarshall Clow
10053d81ceSMarshall Clow#ifndef _LIBCPP_STRING_VIEW
11053d81ceSMarshall Clow#define _LIBCPP_STRING_VIEW
12053d81ceSMarshall Clow
13053d81ceSMarshall Clow/*
14053d81ceSMarshall Clowstring_view synopsis
15053d81ceSMarshall Clow
16053d81ceSMarshall Clownamespace std {
17053d81ceSMarshall Clow
18053d81ceSMarshall Clow    // 7.2, Class template basic_string_view
19053d81ceSMarshall Clow    template<class charT, class traits = char_traits<charT>>
20053d81ceSMarshall Clow        class basic_string_view;
21053d81ceSMarshall Clow
2201ace074SMark de Wever    template<class charT, class traits>
23462f8f06SChristopher Di Bella    inline constexpr bool ranges::enable_view<basic_string_view<charT, traits>> = true;
24462f8f06SChristopher Di Bella
25462f8f06SChristopher Di Bella    template<class charT, class traits>
2601ace074SMark de Wever    inline constexpr bool ranges::enable_borrowed_range<basic_string_view<charT, traits>> = true;  // C++20
2701ace074SMark de Wever
28053d81ceSMarshall Clow    // 7.9, basic_string_view non-member comparison functions
29053d81ceSMarshall Clow    template<class charT, class traits>
30053d81ceSMarshall Clow    constexpr bool operator==(basic_string_view<charT, traits> x,
31053d81ceSMarshall Clow                              basic_string_view<charT, traits> y) noexcept;
32053d81ceSMarshall Clow    template<class charT, class traits>
33053d81ceSMarshall Clow    constexpr bool operator!=(basic_string_view<charT, traits> x,
34053d81ceSMarshall Clow                              basic_string_view<charT, traits> y) noexcept;
35053d81ceSMarshall Clow    template<class charT, class traits>
36053d81ceSMarshall Clow    constexpr bool operator< (basic_string_view<charT, traits> x,
37053d81ceSMarshall Clow                                 basic_string_view<charT, traits> y) noexcept;
38053d81ceSMarshall Clow    template<class charT, class traits>
39053d81ceSMarshall Clow    constexpr bool operator> (basic_string_view<charT, traits> x,
40053d81ceSMarshall Clow                              basic_string_view<charT, traits> y) noexcept;
41053d81ceSMarshall Clow    template<class charT, class traits>
42053d81ceSMarshall Clow    constexpr bool operator<=(basic_string_view<charT, traits> x,
43053d81ceSMarshall Clow                                 basic_string_view<charT, traits> y) noexcept;
44053d81ceSMarshall Clow    template<class charT, class traits>
45053d81ceSMarshall Clow    constexpr bool operator>=(basic_string_view<charT, traits> x,
46053d81ceSMarshall Clow                              basic_string_view<charT, traits> y) noexcept;
47053d81ceSMarshall Clow    // see below, sufficient additional overloads of comparison functions
48053d81ceSMarshall Clow
49053d81ceSMarshall Clow    // 7.10, Inserters and extractors
50053d81ceSMarshall Clow    template<class charT, class traits>
51053d81ceSMarshall Clow      basic_ostream<charT, traits>&
52053d81ceSMarshall Clow        operator<<(basic_ostream<charT, traits>& os,
53053d81ceSMarshall Clow                   basic_string_view<charT, traits> str);
54053d81ceSMarshall Clow
55053d81ceSMarshall Clow    // basic_string_view typedef names
56053d81ceSMarshall Clow    typedef basic_string_view<char> string_view;
5728f82becSMarek Kurdej    typedef basic_string_view<char8_t> u8string_view; // C++20
58053d81ceSMarshall Clow    typedef basic_string_view<char16_t> u16string_view;
59053d81ceSMarshall Clow    typedef basic_string_view<char32_t> u32string_view;
60053d81ceSMarshall Clow    typedef basic_string_view<wchar_t> wstring_view;
61053d81ceSMarshall Clow
62053d81ceSMarshall Clow    template<class charT, class traits = char_traits<charT>>
63053d81ceSMarshall Clow    class basic_string_view {
64053d81ceSMarshall Clow      public:
65053d81ceSMarshall Clow      // types
66053d81ceSMarshall Clow      typedef traits traits_type;
67053d81ceSMarshall Clow      typedef charT value_type;
68053d81ceSMarshall Clow      typedef charT* pointer;
69053d81ceSMarshall Clow      typedef const charT* const_pointer;
70053d81ceSMarshall Clow      typedef charT& reference;
71053d81ceSMarshall Clow      typedef const charT& const_reference;
72053d81ceSMarshall Clow      typedef implementation-defined const_iterator;
73053d81ceSMarshall Clow      typedef const_iterator iterator;
74053d81ceSMarshall Clow      typedef reverse_iterator<const_iterator> const_reverse_iterator;
75053d81ceSMarshall Clow      typedef const_reverse_iterator reverse_iterator;
76053d81ceSMarshall Clow      typedef size_t size_type;
77053d81ceSMarshall Clow      typedef ptrdiff_t difference_type;
78053d81ceSMarshall Clow      static constexpr size_type npos = size_type(-1);
79053d81ceSMarshall Clow
80053d81ceSMarshall Clow      // 7.3, basic_string_view constructors and assignment operators
81053d81ceSMarshall Clow      constexpr basic_string_view() noexcept;
82053d81ceSMarshall Clow      constexpr basic_string_view(const basic_string_view&) noexcept = default;
83053d81ceSMarshall Clow      basic_string_view& operator=(const basic_string_view&) noexcept = default;
84053d81ceSMarshall Clow      template<class Allocator>
85053d81ceSMarshall Clow      constexpr basic_string_view(const charT* str);
86775caa58SMarek Kurdej      basic_string_view(nullptr_t) = delete; // C++2b
87053d81ceSMarshall Clow      constexpr basic_string_view(const charT* str, size_type len);
884be7f489SJoe Loser      template <class It, class End>
894be7f489SJoe Loser      constexpr basic_string_view(It begin, End end); // C++20
90053d81ceSMarshall Clow
91053d81ceSMarshall Clow      // 7.4, basic_string_view iterator support
92053d81ceSMarshall Clow      constexpr const_iterator begin() const noexcept;
93053d81ceSMarshall Clow      constexpr const_iterator end() const noexcept;
94053d81ceSMarshall Clow      constexpr const_iterator cbegin() const noexcept;
95053d81ceSMarshall Clow      constexpr const_iterator cend() const noexcept;
96053d81ceSMarshall Clow      const_reverse_iterator rbegin() const noexcept;
97053d81ceSMarshall Clow      const_reverse_iterator rend() const noexcept;
98053d81ceSMarshall Clow      const_reverse_iterator crbegin() const noexcept;
99053d81ceSMarshall Clow      const_reverse_iterator crend() const noexcept;
100053d81ceSMarshall Clow
101053d81ceSMarshall Clow      // 7.5, basic_string_view capacity
102053d81ceSMarshall Clow      constexpr size_type size() const noexcept;
103053d81ceSMarshall Clow      constexpr size_type length() const noexcept;
104053d81ceSMarshall Clow      constexpr size_type max_size() const noexcept;
105053d81ceSMarshall Clow      constexpr bool empty() const noexcept;
106053d81ceSMarshall Clow
107053d81ceSMarshall Clow      // 7.6, basic_string_view element access
108053d81ceSMarshall Clow      constexpr const_reference operator[](size_type pos) const;
109053d81ceSMarshall Clow      constexpr const_reference at(size_type pos) const;
110053d81ceSMarshall Clow      constexpr const_reference front() const;
111053d81ceSMarshall Clow      constexpr const_reference back() const;
112053d81ceSMarshall Clow      constexpr const_pointer data() const noexcept;
113053d81ceSMarshall Clow
114053d81ceSMarshall Clow      // 7.7, basic_string_view modifiers
115053d81ceSMarshall Clow      constexpr void remove_prefix(size_type n);
116053d81ceSMarshall Clow      constexpr void remove_suffix(size_type n);
117053d81ceSMarshall Clow      constexpr void swap(basic_string_view& s) noexcept;
118053d81ceSMarshall Clow
11906e2b737SArthur O'Dwyer      size_type copy(charT* s, size_type n, size_type pos = 0) const;  // constexpr in C++20
120053d81ceSMarshall Clow
121053d81ceSMarshall Clow      constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
122053d81ceSMarshall Clow      constexpr int compare(basic_string_view s) const noexcept;
123053d81ceSMarshall Clow      constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
124053d81ceSMarshall Clow      constexpr int compare(size_type pos1, size_type n1,
125053d81ceSMarshall Clow                            basic_string_view s, size_type pos2, size_type n2) const;
126053d81ceSMarshall Clow      constexpr int compare(const charT* s) const;
127053d81ceSMarshall Clow      constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
128053d81ceSMarshall Clow      constexpr int compare(size_type pos1, size_type n1,
129053d81ceSMarshall Clow                            const charT* s, size_type n2) const;
130053d81ceSMarshall Clow      constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
131053d81ceSMarshall Clow      constexpr size_type find(charT c, size_type pos = 0) const noexcept;
132dea74b28Szoecarver      constexpr size_type find(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
133dea74b28Szoecarver      constexpr size_type find(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension
134053d81ceSMarshall Clow      constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
135053d81ceSMarshall Clow      constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
136dea74b28Szoecarver      constexpr size_type rfind(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
137dea74b28Szoecarver      constexpr size_type rfind(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension
138053d81ceSMarshall Clow      constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
139053d81ceSMarshall Clow      constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
140dea74b28Szoecarver      constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
141dea74b28Szoecarver      constexpr size_type find_first_of(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension
142053d81ceSMarshall Clow      constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
143053d81ceSMarshall Clow      constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
144dea74b28Szoecarver      constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
145dea74b28Szoecarver      constexpr size_type find_last_of(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension
146053d81ceSMarshall Clow      constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
147053d81ceSMarshall Clow      constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
148dea74b28Szoecarver      constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
149dea74b28Szoecarver      constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const noexcept; // noexcept as an extension
150053d81ceSMarshall Clow      constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
151053d81ceSMarshall Clow      constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
152dea74b28Szoecarver      constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const noexcept; // noexcept as an extension
153dea74b28Szoecarver      constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const noexcept; // noexcept as an extension
154053d81ceSMarshall Clow
155044b892cSMarek Kurdej      constexpr bool starts_with(basic_string_view s) const noexcept; // C++20
156044b892cSMarek Kurdej      constexpr bool starts_with(charT c) const noexcept;             // C++20
157044b892cSMarek Kurdej      constexpr bool starts_with(const charT* s) const;               // C++20
158044b892cSMarek Kurdej      constexpr bool ends_with(basic_string_view s) const noexcept;   // C++20
159044b892cSMarek Kurdej      constexpr bool ends_with(charT c) const noexcept;               // C++20
160044b892cSMarek Kurdej      constexpr bool ends_with(const charT* s) const;                 // C++20
161800259c9SMarshall Clow
1626ac9cb2aSWim Leflere      constexpr bool contains(basic_string_view s) const noexcept; // C++2b
1636ac9cb2aSWim Leflere      constexpr bool contains(charT c) const noexcept;             // C++2b
1646ac9cb2aSWim Leflere      constexpr bool contains(const charT* s) const;               // C++2b
1656ac9cb2aSWim Leflere
166053d81ceSMarshall Clow     private:
167053d81ceSMarshall Clow      const_pointer data_;  // exposition only
168053d81ceSMarshall Clow      size_type     size_;  // exposition only
169053d81ceSMarshall Clow    };
170053d81ceSMarshall Clow
1714be7f489SJoe Loser  // basic_string_view deduction guides
1724be7f489SJoe Loser  template<class It, class End>
1734be7f489SJoe Loser    basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>; // C++20
1744be7f489SJoe Loser
175053d81ceSMarshall Clow  // 7.11, Hash support
176053d81ceSMarshall Clow  template <class T> struct hash;
177053d81ceSMarshall Clow  template <> struct hash<string_view>;
17828f82becSMarek Kurdej  template <> struct hash<u8string_view>; // C++20
179053d81ceSMarshall Clow  template <> struct hash<u16string_view>;
180053d81ceSMarshall Clow  template <> struct hash<u32string_view>;
181053d81ceSMarshall Clow  template <> struct hash<wstring_view>;
182053d81ceSMarshall Clow
18359b48302SMarshall Clow  constexpr basic_string_view<char>     operator "" sv( const char *str,     size_t len ) noexcept;
18459b48302SMarshall Clow  constexpr basic_string_view<wchar_t>  operator "" sv( const wchar_t *str,  size_t len ) noexcept;
18528f82becSMarek Kurdej  constexpr basic_string_view<char8_t>  operator "" sv( const char8_t *str,  size_t len ) noexcept; // C++20
18659b48302SMarshall Clow  constexpr basic_string_view<char16_t> operator "" sv( const char16_t *str, size_t len ) noexcept;
18759b48302SMarshall Clow  constexpr basic_string_view<char32_t> operator "" sv( const char32_t *str, size_t len ) noexcept;
1888fd58a6bSMarshall Clow
189053d81ceSMarshall Clow}  // namespace std
190053d81ceSMarshall Clow
191053d81ceSMarshall Clow
192053d81ceSMarshall Clow*/
193053d81ceSMarshall Clow
1944be7f489SJoe Loser#include <__concepts/convertible_to.h>
1954be7f489SJoe Loser#include <__concepts/same_as.h>
196053d81ceSMarshall Clow#include <__config>
197bfbd73f8SArthur O'Dwyer#include <__debug>
19801ace074SMark de Wever#include <__ranges/enable_borrowed_range.h>
199462f8f06SChristopher Di Bella#include <__ranges/enable_view.h>
200053d81ceSMarshall Clow#include <__string>
201ca648c97SEric Fiselier#include <algorithm>
2022d0f1fa4SArthur O'Dwyer#include <compare>
203bfbd73f8SArthur O'Dwyer#include <iosfwd>
204053d81ceSMarshall Clow#include <iterator>
205ca648c97SEric Fiselier#include <limits>
206ca648c97SEric Fiselier#include <stdexcept>
207f56972e2SMarshall Clow#include <version>
208053d81ceSMarshall Clow
209053d81ceSMarshall Clow#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
210053d81ceSMarshall Clow#pragma GCC system_header
211053d81ceSMarshall Clow#endif
212053d81ceSMarshall Clow
213a016efb1SEric Fiselier_LIBCPP_PUSH_MACROS
214a016efb1SEric Fiselier#include <__undef_macros>
215a016efb1SEric Fiselier
216a016efb1SEric Fiselier
217053d81ceSMarshall Clow_LIBCPP_BEGIN_NAMESPACE_STD
218053d81ceSMarshall Clow
219053d81ceSMarshall Clowtemplate<class _CharT, class _Traits = char_traits<_CharT> >
2202a2c228cSRichard Smith    class _LIBCPP_TEMPLATE_VIS basic_string_view;
2212a2c228cSRichard Smith
2222a2c228cSRichard Smithtypedef basic_string_view<char>     string_view;
2235c40c994SArthur O'Dwyer#ifndef _LIBCPP_HAS_NO_CHAR8_T
2242a2c228cSRichard Smithtypedef basic_string_view<char8_t>  u8string_view;
2252a2c228cSRichard Smith#endif
2262a2c228cSRichard Smithtypedef basic_string_view<char16_t> u16string_view;
2272a2c228cSRichard Smithtypedef basic_string_view<char32_t> u32string_view;
228f4c1258dSLouis Dionne#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2292a2c228cSRichard Smithtypedef basic_string_view<wchar_t>  wstring_view;
230f4c1258dSLouis Dionne#endif
2312a2c228cSRichard Smith
2322a2c228cSRichard Smithtemplate<class _CharT, class _Traits>
2332a2c228cSRichard Smithclass
2342a2c228cSRichard Smith    _LIBCPP_PREFERRED_NAME(string_view)
2355c40c994SArthur O'Dwyer#ifndef _LIBCPP_HAS_NO_CHAR8_T
2362a2c228cSRichard Smith    _LIBCPP_PREFERRED_NAME(u8string_view)
2372a2c228cSRichard Smith#endif
2382a2c228cSRichard Smith    _LIBCPP_PREFERRED_NAME(u16string_view)
2392a2c228cSRichard Smith    _LIBCPP_PREFERRED_NAME(u32string_view)
240f4c1258dSLouis Dionne    _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring_view))
2412a2c228cSRichard Smith    basic_string_view {
242053d81ceSMarshall Clowpublic:
243053d81ceSMarshall Clow    // types
244053d81ceSMarshall Clow    typedef _Traits                                    traits_type;
245053d81ceSMarshall Clow    typedef _CharT                                     value_type;
2467d661bb2SMarshall Clow    typedef _CharT*                                    pointer;
247053d81ceSMarshall Clow    typedef const _CharT*                              const_pointer;
2487d661bb2SMarshall Clow    typedef _CharT&                                    reference;
249053d81ceSMarshall Clow    typedef const _CharT&                              const_reference;
250053d81ceSMarshall Clow    typedef const_pointer                              const_iterator; // See [string.view.iterators]
251053d81ceSMarshall Clow    typedef const_iterator                             iterator;
252053d81ceSMarshall Clow    typedef _VSTD::reverse_iterator<const_iterator>    const_reverse_iterator;
253053d81ceSMarshall Clow    typedef const_reverse_iterator                     reverse_iterator;
254053d81ceSMarshall Clow    typedef size_t                                     size_type;
255053d81ceSMarshall Clow    typedef ptrdiff_t                                  difference_type;
256053d81ceSMarshall Clow    static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
257053d81ceSMarshall Clow
2584a6f3c47SMarshall Clow    static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array");
2594a6f3c47SMarshall Clow    static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string_view must be standard-layout");
2604a6f3c47SMarshall Clow    static_assert(( is_trivial<value_type>::value), "Character type of basic_string_view must be trivial");
2614069c2bcSMarshall Clow    static_assert((is_same<_CharT, typename traits_type::char_type>::value),
2624069c2bcSMarshall Clow                  "traits_type::char_type must be the same type as CharT");
2634069c2bcSMarshall Clow
264053d81ceSMarshall Clow    // [string.view.cons], construct/copy
265053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
266053d81ceSMarshall Clow    basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
267053d81ceSMarshall Clow
268ae0e037fSArthur O'Dwyer    _LIBCPP_INLINE_VISIBILITY
269053d81ceSMarshall Clow    basic_string_view(const basic_string_view&) _NOEXCEPT = default;
270053d81ceSMarshall Clow
271ae0e037fSArthur O'Dwyer    _LIBCPP_INLINE_VISIBILITY
272053d81ceSMarshall Clow    basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
273053d81ceSMarshall Clow
274053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
275ac2b3e3aSMarshall Clow    basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
276053d81ceSMarshall Clow        : __data(__s), __size(__len)
277053d81ceSMarshall Clow    {
278f67524d4SMarshall Clow#if _LIBCPP_STD_VER > 11
279f67524d4SMarshall Clow    _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
280f67524d4SMarshall Clow#endif
281053d81ceSMarshall Clow    }
282053d81ceSMarshall Clow
2834be7f489SJoe Loser#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
2844be7f489SJoe Loser    template <contiguous_iterator _It, sized_sentinel_for<_It> _End>
2854be7f489SJoe Loser      requires (same_as<iter_value_t<_It>, _CharT> && !convertible_to<_End, size_type>)
2864be7f489SJoe Loser    constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end)
2874be7f489SJoe Loser       : __data(_VSTD::to_address(__begin)), __size(__end - __begin)
2884be7f489SJoe Loser    {
2894be7f489SJoe Loser      _LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range");
2904be7f489SJoe Loser    }
2914be7f489SJoe Loser#endif
2924be7f489SJoe Loser
293053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
294053d81ceSMarshall Clow    basic_string_view(const _CharT* __s)
295d586f92cSArthur O'Dwyer        : __data(__s), __size(_VSTD::__char_traits_length_checked<_Traits>(__s)) {}
296053d81ceSMarshall Clow
297775caa58SMarek Kurdej#if _LIBCPP_STD_VER > 20
298775caa58SMarek Kurdej    basic_string_view(nullptr_t) = delete;
299775caa58SMarek Kurdej#endif
300775caa58SMarek Kurdej
301053d81ceSMarshall Clow    // [string.view.iterators], iterators
302053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
303053d81ceSMarshall Clow    const_iterator begin()  const _NOEXCEPT { return cbegin(); }
304053d81ceSMarshall Clow
305053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
306053d81ceSMarshall Clow    const_iterator end()    const _NOEXCEPT { return cend(); }
307053d81ceSMarshall Clow
308053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
309053d81ceSMarshall Clow    const_iterator cbegin() const _NOEXCEPT { return __data; }
310053d81ceSMarshall Clow
311053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
312053d81ceSMarshall Clow    const_iterator cend()   const _NOEXCEPT { return __data + __size; }
313053d81ceSMarshall Clow
314cddeb751SMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
315053d81ceSMarshall Clow    const_reverse_iterator rbegin()   const _NOEXCEPT { return const_reverse_iterator(cend()); }
316053d81ceSMarshall Clow
317cddeb751SMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
318053d81ceSMarshall Clow    const_reverse_iterator rend()     const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
319053d81ceSMarshall Clow
320cddeb751SMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
321053d81ceSMarshall Clow    const_reverse_iterator crbegin()  const _NOEXCEPT { return const_reverse_iterator(cend()); }
322053d81ceSMarshall Clow
323cddeb751SMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
324053d81ceSMarshall Clow    const_reverse_iterator crend()    const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
325053d81ceSMarshall Clow
326053d81ceSMarshall Clow    // [string.view.capacity], capacity
327053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
328053d81ceSMarshall Clow    size_type size()     const _NOEXCEPT { return __size; }
329053d81ceSMarshall Clow
330053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
331053d81ceSMarshall Clow    size_type length()   const _NOEXCEPT { return __size; }
332053d81ceSMarshall Clow
333053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
334053d81ceSMarshall Clow    size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max(); }
335053d81ceSMarshall Clow
33625a7ba45SMarshall Clow    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
33725a7ba45SMarshall Clow    bool empty()         const _NOEXCEPT { return __size == 0; }
338053d81ceSMarshall Clow
339053d81ceSMarshall Clow    // [string.view.access], element access
340053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3419eff07a7SChris Palmer    const_reference operator[](size_type __pos) const _NOEXCEPT {
3429eff07a7SChris Palmer      return _LIBCPP_ASSERT(__pos < size(), "string_view[] index out of bounds"), __data[__pos];
3439eff07a7SChris Palmer    }
344053d81ceSMarshall Clow
345053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
346053d81ceSMarshall Clow    const_reference at(size_type __pos) const
347053d81ceSMarshall Clow    {
348053d81ceSMarshall Clow        return __pos >= size()
3490fc8cec7SMarshall Clow            ? (__throw_out_of_range("string_view::at"), __data[0])
350053d81ceSMarshall Clow            : __data[__pos];
351053d81ceSMarshall Clow    }
352053d81ceSMarshall Clow
353053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3549ea0e473SMarshall Clow    const_reference front() const _NOEXCEPT
355053d81ceSMarshall Clow    {
356053d81ceSMarshall Clow        return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
357053d81ceSMarshall Clow    }
358053d81ceSMarshall Clow
359053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
3609ea0e473SMarshall Clow    const_reference back() const _NOEXCEPT
361053d81ceSMarshall Clow    {
362053d81ceSMarshall Clow        return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
363053d81ceSMarshall Clow    }
364053d81ceSMarshall Clow
365053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
366053d81ceSMarshall Clow    const_pointer data() const _NOEXCEPT { return __data; }
367053d81ceSMarshall Clow
368053d81ceSMarshall Clow    // [string.view.modifiers], modifiers:
369053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
370053d81ceSMarshall Clow    void remove_prefix(size_type __n) _NOEXCEPT
371053d81ceSMarshall Clow    {
372053d81ceSMarshall Clow        _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
373053d81ceSMarshall Clow        __data += __n;
374053d81ceSMarshall Clow        __size -= __n;
375053d81ceSMarshall Clow    }
376053d81ceSMarshall Clow
377053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
378053d81ceSMarshall Clow    void remove_suffix(size_type __n) _NOEXCEPT
379053d81ceSMarshall Clow    {
380053d81ceSMarshall Clow        _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
381053d81ceSMarshall Clow        __size -= __n;
382053d81ceSMarshall Clow    }
383053d81ceSMarshall Clow
384053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
385053d81ceSMarshall Clow    void swap(basic_string_view& __other) _NOEXCEPT
386053d81ceSMarshall Clow    {
387053d81ceSMarshall Clow        const value_type *__p = __data;
388053d81ceSMarshall Clow        __data = __other.__data;
389053d81ceSMarshall Clow        __other.__data = __p;
390053d81ceSMarshall Clow
391053d81ceSMarshall Clow        size_type __sz = __size;
392053d81ceSMarshall Clow        __size = __other.__size;
393053d81ceSMarshall Clow        __other.__size = __sz;
394053d81ceSMarshall Clow    }
395053d81ceSMarshall Clow
39606e2b737SArthur O'Dwyer    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
397053d81ceSMarshall Clow    size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
398053d81ceSMarshall Clow    {
399053d81ceSMarshall Clow        if (__pos > size())
4000fc8cec7SMarshall Clow            __throw_out_of_range("string_view::copy");
401053d81ceSMarshall Clow        size_type __rlen = _VSTD::min(__n, size() - __pos);
4021c7fe126SMarshall Clow        _Traits::copy(__s, data() + __pos, __rlen);
403053d81ceSMarshall Clow        return __rlen;
404053d81ceSMarshall Clow    }
405053d81ceSMarshall Clow
406053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
407053d81ceSMarshall Clow    basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
408053d81ceSMarshall Clow    {
409053d81ceSMarshall Clow        return __pos > size()
4100fc8cec7SMarshall Clow            ? (__throw_out_of_range("string_view::substr"), basic_string_view())
411053d81ceSMarshall Clow            : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
412053d81ceSMarshall Clow    }
413053d81ceSMarshall Clow
414053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
415053d81ceSMarshall Clow    {
416053d81ceSMarshall Clow        size_type __rlen = _VSTD::min( size(), __sv.size());
417053d81ceSMarshall Clow        int __retval = _Traits::compare(data(), __sv.data(), __rlen);
418053d81ceSMarshall Clow        if ( __retval == 0 ) // first __rlen chars matched
419053d81ceSMarshall Clow            __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
420053d81ceSMarshall Clow        return __retval;
421053d81ceSMarshall Clow    }
422053d81ceSMarshall Clow
423053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
424053d81ceSMarshall Clow    int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
425053d81ceSMarshall Clow    {
426053d81ceSMarshall Clow        return substr(__pos1, __n1).compare(__sv);
427053d81ceSMarshall Clow    }
428053d81ceSMarshall Clow
429053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
430053d81ceSMarshall Clow    int compare(                       size_type __pos1, size_type __n1,
4319ffacf3dSEric Fiselier                basic_string_view __sv, size_type __pos2, size_type __n2) const
432053d81ceSMarshall Clow    {
4339ffacf3dSEric Fiselier        return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
434053d81ceSMarshall Clow    }
435053d81ceSMarshall Clow
436053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
437aa849bc2SMarshall Clow    int compare(const _CharT* __s) const _NOEXCEPT
438053d81ceSMarshall Clow    {
439053d81ceSMarshall Clow        return compare(basic_string_view(__s));
440053d81ceSMarshall Clow    }
441053d81ceSMarshall Clow
442053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
443053d81ceSMarshall Clow    int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
444053d81ceSMarshall Clow    {
445053d81ceSMarshall Clow        return substr(__pos1, __n1).compare(basic_string_view(__s));
446053d81ceSMarshall Clow    }
447053d81ceSMarshall Clow
448053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
449053d81ceSMarshall Clow    int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
450053d81ceSMarshall Clow    {
451053d81ceSMarshall Clow        return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
452053d81ceSMarshall Clow    }
453053d81ceSMarshall Clow
454053d81ceSMarshall Clow    // find
455053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
456053d81ceSMarshall Clow    size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
457053d81ceSMarshall Clow    {
458053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
459053d81ceSMarshall Clow        return __str_find<value_type, size_type, traits_type, npos>
460053d81ceSMarshall Clow            (data(), size(), __s.data(), __pos, __s.size());
461053d81ceSMarshall Clow    }
462053d81ceSMarshall Clow
463053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
464053d81ceSMarshall Clow    size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
465053d81ceSMarshall Clow    {
466053d81ceSMarshall Clow        return __str_find<value_type, size_type, traits_type, npos>
467053d81ceSMarshall Clow            (data(), size(), __c, __pos);
468053d81ceSMarshall Clow    }
469053d81ceSMarshall Clow
470053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
471dea74b28Szoecarver    size_type find(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
472053d81ceSMarshall Clow    {
473053d81ceSMarshall Clow        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
474053d81ceSMarshall Clow        return __str_find<value_type, size_type, traits_type, npos>
475053d81ceSMarshall Clow            (data(), size(), __s, __pos, __n);
476053d81ceSMarshall Clow    }
477053d81ceSMarshall Clow
478053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
479dea74b28Szoecarver    size_type find(const _CharT* __s, size_type __pos = 0) const _NOEXCEPT
480053d81ceSMarshall Clow    {
481053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");
482053d81ceSMarshall Clow        return __str_find<value_type, size_type, traits_type, npos>
483053d81ceSMarshall Clow            (data(), size(), __s, __pos, traits_type::length(__s));
484053d81ceSMarshall Clow    }
485053d81ceSMarshall Clow
486053d81ceSMarshall Clow    // rfind
487053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
488053d81ceSMarshall Clow    size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
489053d81ceSMarshall Clow    {
490053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
491053d81ceSMarshall Clow        return __str_rfind<value_type, size_type, traits_type, npos>
492053d81ceSMarshall Clow            (data(), size(), __s.data(), __pos, __s.size());
493053d81ceSMarshall Clow    }
494053d81ceSMarshall Clow
495053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
496053d81ceSMarshall Clow    size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
497053d81ceSMarshall Clow    {
498053d81ceSMarshall Clow        return __str_rfind<value_type, size_type, traits_type, npos>
499053d81ceSMarshall Clow            (data(), size(), __c, __pos);
500053d81ceSMarshall Clow    }
501053d81ceSMarshall Clow
502053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
503dea74b28Szoecarver    size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
504053d81ceSMarshall Clow    {
505053d81ceSMarshall Clow        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
506053d81ceSMarshall Clow        return __str_rfind<value_type, size_type, traits_type, npos>
507053d81ceSMarshall Clow            (data(), size(), __s, __pos, __n);
508053d81ceSMarshall Clow    }
509053d81ceSMarshall Clow
510053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
511dea74b28Szoecarver    size_type rfind(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
512053d81ceSMarshall Clow    {
513053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");
514053d81ceSMarshall Clow        return __str_rfind<value_type, size_type, traits_type, npos>
515053d81ceSMarshall Clow            (data(), size(), __s, __pos, traits_type::length(__s));
516053d81ceSMarshall Clow    }
517053d81ceSMarshall Clow
518053d81ceSMarshall Clow    // find_first_of
519053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
520053d81ceSMarshall Clow    size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
521053d81ceSMarshall Clow    {
522053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
523053d81ceSMarshall Clow        return __str_find_first_of<value_type, size_type, traits_type, npos>
524053d81ceSMarshall Clow            (data(), size(), __s.data(), __pos, __s.size());
525053d81ceSMarshall Clow    }
526053d81ceSMarshall Clow
527053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
528053d81ceSMarshall Clow    size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
529053d81ceSMarshall Clow    { return find(__c, __pos); }
530053d81ceSMarshall Clow
531053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
532dea74b28Szoecarver    size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
533053d81ceSMarshall Clow    {
534053d81ceSMarshall Clow        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
535053d81ceSMarshall Clow        return __str_find_first_of<value_type, size_type, traits_type, npos>
536053d81ceSMarshall Clow            (data(), size(), __s, __pos, __n);
537053d81ceSMarshall Clow    }
538053d81ceSMarshall Clow
539053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
540dea74b28Szoecarver    size_type find_first_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT
541053d81ceSMarshall Clow    {
542053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");
543053d81ceSMarshall Clow        return __str_find_first_of<value_type, size_type, traits_type, npos>
544053d81ceSMarshall Clow            (data(), size(), __s, __pos, traits_type::length(__s));
545053d81ceSMarshall Clow    }
546053d81ceSMarshall Clow
547053d81ceSMarshall Clow    // find_last_of
548053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
549053d81ceSMarshall Clow    size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
550053d81ceSMarshall Clow    {
551053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
552053d81ceSMarshall Clow        return __str_find_last_of<value_type, size_type, traits_type, npos>
553053d81ceSMarshall Clow            (data(), size(), __s.data(), __pos, __s.size());
554053d81ceSMarshall Clow    }
555053d81ceSMarshall Clow
556053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
557053d81ceSMarshall Clow    size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
558053d81ceSMarshall Clow    { return rfind(__c, __pos); }
559053d81ceSMarshall Clow
560053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
561dea74b28Szoecarver    size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
562053d81ceSMarshall Clow    {
563053d81ceSMarshall Clow        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
564053d81ceSMarshall Clow        return __str_find_last_of<value_type, size_type, traits_type, npos>
565053d81ceSMarshall Clow            (data(), size(), __s, __pos, __n);
566053d81ceSMarshall Clow    }
567053d81ceSMarshall Clow
568053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
569dea74b28Szoecarver    size_type find_last_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
570053d81ceSMarshall Clow    {
571053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");
572053d81ceSMarshall Clow        return __str_find_last_of<value_type, size_type, traits_type, npos>
573053d81ceSMarshall Clow            (data(), size(), __s, __pos, traits_type::length(__s));
574053d81ceSMarshall Clow    }
575053d81ceSMarshall Clow
576053d81ceSMarshall Clow    // find_first_not_of
577053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
578053d81ceSMarshall Clow    size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
579053d81ceSMarshall Clow    {
580053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
581053d81ceSMarshall Clow        return __str_find_first_not_of<value_type, size_type, traits_type, npos>
582053d81ceSMarshall Clow            (data(), size(), __s.data(), __pos, __s.size());
583053d81ceSMarshall Clow    }
584053d81ceSMarshall Clow
585053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
586053d81ceSMarshall Clow    size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
587053d81ceSMarshall Clow    {
588053d81ceSMarshall Clow        return __str_find_first_not_of<value_type, size_type, traits_type, npos>
589053d81ceSMarshall Clow            (data(), size(), __c, __pos);
590053d81ceSMarshall Clow    }
591053d81ceSMarshall Clow
592053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
593dea74b28Szoecarver    size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
594053d81ceSMarshall Clow    {
595053d81ceSMarshall Clow        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
596053d81ceSMarshall Clow        return __str_find_first_not_of<value_type, size_type, traits_type, npos>
597053d81ceSMarshall Clow            (data(), size(), __s, __pos, __n);
598053d81ceSMarshall Clow    }
599053d81ceSMarshall Clow
600053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
601dea74b28Szoecarver    size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const _NOEXCEPT
602053d81ceSMarshall Clow    {
603053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
604053d81ceSMarshall Clow        return __str_find_first_not_of<value_type, size_type, traits_type, npos>
605053d81ceSMarshall Clow            (data(), size(), __s, __pos, traits_type::length(__s));
606053d81ceSMarshall Clow    }
607053d81ceSMarshall Clow
608053d81ceSMarshall Clow    // find_last_not_of
609053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
610053d81ceSMarshall Clow    size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
611053d81ceSMarshall Clow    {
612053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
613053d81ceSMarshall Clow        return __str_find_last_not_of<value_type, size_type, traits_type, npos>
614053d81ceSMarshall Clow            (data(), size(), __s.data(), __pos, __s.size());
615053d81ceSMarshall Clow    }
616053d81ceSMarshall Clow
617053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
618053d81ceSMarshall Clow    size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
619053d81ceSMarshall Clow    {
620053d81ceSMarshall Clow        return __str_find_last_not_of<value_type, size_type, traits_type, npos>
621053d81ceSMarshall Clow            (data(), size(), __c, __pos);
622053d81ceSMarshall Clow    }
623053d81ceSMarshall Clow
624053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
625dea74b28Szoecarver    size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const _NOEXCEPT
626053d81ceSMarshall Clow    {
627053d81ceSMarshall Clow        _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
628053d81ceSMarshall Clow        return __str_find_last_not_of<value_type, size_type, traits_type, npos>
629053d81ceSMarshall Clow            (data(), size(), __s, __pos, __n);
630053d81ceSMarshall Clow    }
631053d81ceSMarshall Clow
632053d81ceSMarshall Clow    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
633dea74b28Szoecarver    size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const _NOEXCEPT
634053d81ceSMarshall Clow    {
635053d81ceSMarshall Clow        _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
636053d81ceSMarshall Clow        return __str_find_last_not_of<value_type, size_type, traits_type, npos>
637053d81ceSMarshall Clow            (data(), size(), __s, __pos, traits_type::length(__s));
638053d81ceSMarshall Clow    }
639053d81ceSMarshall Clow
640800259c9SMarshall Clow#if _LIBCPP_STD_VER > 17
641ae0e037fSArthur O'Dwyer    constexpr _LIBCPP_INLINE_VISIBILITY
642ae0e037fSArthur O'Dwyer    bool starts_with(basic_string_view __s) const noexcept
643800259c9SMarshall Clow    { return size() >= __s.size() && compare(0, __s.size(), __s) == 0; }
644800259c9SMarshall Clow
645ae0e037fSArthur O'Dwyer    constexpr _LIBCPP_INLINE_VISIBILITY
646ae0e037fSArthur O'Dwyer    bool starts_with(value_type __c) const noexcept
647800259c9SMarshall Clow    { return !empty() && _Traits::eq(front(), __c); }
648800259c9SMarshall Clow
649ae0e037fSArthur O'Dwyer    constexpr _LIBCPP_INLINE_VISIBILITY
650ae0e037fSArthur O'Dwyer    bool starts_with(const value_type* __s) const noexcept
651800259c9SMarshall Clow    { return starts_with(basic_string_view(__s)); }
652800259c9SMarshall Clow
653ae0e037fSArthur O'Dwyer    constexpr _LIBCPP_INLINE_VISIBILITY
654ae0e037fSArthur O'Dwyer    bool ends_with(basic_string_view __s) const noexcept
655800259c9SMarshall Clow    { return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; }
656800259c9SMarshall Clow
657ae0e037fSArthur O'Dwyer    constexpr _LIBCPP_INLINE_VISIBILITY
658ae0e037fSArthur O'Dwyer    bool ends_with(value_type __c) const noexcept
659800259c9SMarshall Clow    { return !empty() && _Traits::eq(back(), __c); }
660800259c9SMarshall Clow
661ae0e037fSArthur O'Dwyer    constexpr _LIBCPP_INLINE_VISIBILITY
662ae0e037fSArthur O'Dwyer    bool ends_with(const value_type* __s) const noexcept
663800259c9SMarshall Clow    { return ends_with(basic_string_view(__s)); }
664800259c9SMarshall Clow#endif
665800259c9SMarshall Clow
6666ac9cb2aSWim Leflere#if _LIBCPP_STD_VER > 20
6676ac9cb2aSWim Leflere    constexpr _LIBCPP_INLINE_VISIBILITY
6686ac9cb2aSWim Leflere    bool contains(basic_string_view __sv) const noexcept
6696ac9cb2aSWim Leflere    { return find(__sv) != npos; }
6706ac9cb2aSWim Leflere
6716ac9cb2aSWim Leflere    constexpr _LIBCPP_INLINE_VISIBILITY
6726ac9cb2aSWim Leflere    bool contains(value_type __c) const noexcept
6736ac9cb2aSWim Leflere    { return find(__c) != npos; }
6746ac9cb2aSWim Leflere
6756ac9cb2aSWim Leflere    constexpr _LIBCPP_INLINE_VISIBILITY
6766ac9cb2aSWim Leflere    bool contains(const value_type* __s) const
6776ac9cb2aSWim Leflere    { return find(__s) != npos; }
6786ac9cb2aSWim Leflere#endif
6796ac9cb2aSWim Leflere
680053d81ceSMarshall Clowprivate:
681053d81ceSMarshall Clow    const   value_type* __data;
682053d81ceSMarshall Clow    size_type           __size;
683053d81ceSMarshall Clow};
684053d81ceSMarshall Clow
68501ace074SMark de Wever#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
68601ace074SMark de Wevertemplate <class _CharT, class _Traits>
687462f8f06SChristopher Di Bellainline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true;
688462f8f06SChristopher Di Bella
689462f8f06SChristopher Di Bellatemplate <class _CharT, class _Traits>
69001ace074SMark de Weverinline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true;
69101ace074SMark de Wever#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
692053d81ceSMarshall Clow
6934be7f489SJoe Loser// [string.view.deduct]
6944be7f489SJoe Loser
6954be7f489SJoe Loser#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
6964be7f489SJoe Losertemplate <contiguous_iterator _It, sized_sentinel_for<_It> _End>
6974be7f489SJoe Loser  basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>;
6984be7f489SJoe Loser#endif
6994be7f489SJoe Loser
700053d81ceSMarshall Clow// [string.view.comparison]
701053d81ceSMarshall Clow// operator ==
702053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
703053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
704053d81ceSMarshall Clowbool operator==(basic_string_view<_CharT, _Traits> __lhs,
705053d81ceSMarshall Clow                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
706053d81ceSMarshall Clow{
707053d81ceSMarshall Clow    if ( __lhs.size() != __rhs.size()) return false;
708053d81ceSMarshall Clow    return __lhs.compare(__rhs) == 0;
709053d81ceSMarshall Clow}
710053d81ceSMarshall Clow
711053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
712053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
713053d81ceSMarshall Clowbool operator==(basic_string_view<_CharT, _Traits> __lhs,
714053d81ceSMarshall Clow                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
715053d81ceSMarshall Clow{
716053d81ceSMarshall Clow    if ( __lhs.size() != __rhs.size()) return false;
717053d81ceSMarshall Clow    return __lhs.compare(__rhs) == 0;
718053d81ceSMarshall Clow}
719053d81ceSMarshall Clow
720053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
721053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
722053d81ceSMarshall Clowbool operator==(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
723053d81ceSMarshall Clow                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
724053d81ceSMarshall Clow{
725053d81ceSMarshall Clow    if ( __lhs.size() != __rhs.size()) return false;
726053d81ceSMarshall Clow    return __lhs.compare(__rhs) == 0;
727053d81ceSMarshall Clow}
728053d81ceSMarshall Clow
729053d81ceSMarshall Clow
730053d81ceSMarshall Clow// operator !=
731053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
732053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
733053d81ceSMarshall Clowbool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
734053d81ceSMarshall Clow{
735053d81ceSMarshall Clow    if ( __lhs.size() != __rhs.size())
736053d81ceSMarshall Clow        return true;
737053d81ceSMarshall Clow    return __lhs.compare(__rhs) != 0;
738053d81ceSMarshall Clow}
739053d81ceSMarshall Clow
740053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
741053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
742053d81ceSMarshall Clowbool operator!=(basic_string_view<_CharT, _Traits> __lhs,
743053d81ceSMarshall Clow                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
744053d81ceSMarshall Clow{
745053d81ceSMarshall Clow    if ( __lhs.size() != __rhs.size())
746053d81ceSMarshall Clow        return true;
747053d81ceSMarshall Clow    return __lhs.compare(__rhs) != 0;
748053d81ceSMarshall Clow}
749053d81ceSMarshall Clow
750053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
751053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
752053d81ceSMarshall Clowbool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
753053d81ceSMarshall Clow                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
754053d81ceSMarshall Clow{
755053d81ceSMarshall Clow    if ( __lhs.size() != __rhs.size())
756053d81ceSMarshall Clow        return true;
757053d81ceSMarshall Clow    return __lhs.compare(__rhs) != 0;
758053d81ceSMarshall Clow}
759053d81ceSMarshall Clow
760053d81ceSMarshall Clow
761053d81ceSMarshall Clow// operator <
762053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
763053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
764053d81ceSMarshall Clowbool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
765053d81ceSMarshall Clow{
766053d81ceSMarshall Clow    return __lhs.compare(__rhs) < 0;
767053d81ceSMarshall Clow}
768053d81ceSMarshall Clow
769053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
770053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
771053d81ceSMarshall Clowbool operator<(basic_string_view<_CharT, _Traits> __lhs,
772053d81ceSMarshall Clow                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
773053d81ceSMarshall Clow{
774053d81ceSMarshall Clow    return __lhs.compare(__rhs) < 0;
775053d81ceSMarshall Clow}
776053d81ceSMarshall Clow
777053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
778053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
779053d81ceSMarshall Clowbool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
780053d81ceSMarshall Clow                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
781053d81ceSMarshall Clow{
782053d81ceSMarshall Clow    return __lhs.compare(__rhs) < 0;
783053d81ceSMarshall Clow}
784053d81ceSMarshall Clow
785053d81ceSMarshall Clow
786053d81ceSMarshall Clow// operator >
787053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
788053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
789053d81ceSMarshall Clowbool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
790053d81ceSMarshall Clow{
791053d81ceSMarshall Clow    return __lhs.compare(__rhs) > 0;
792053d81ceSMarshall Clow}
793053d81ceSMarshall Clow
794053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
795053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
796053d81ceSMarshall Clowbool operator>(basic_string_view<_CharT, _Traits> __lhs,
797053d81ceSMarshall Clow                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
798053d81ceSMarshall Clow{
799053d81ceSMarshall Clow    return __lhs.compare(__rhs) > 0;
800053d81ceSMarshall Clow}
801053d81ceSMarshall Clow
802053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
803053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
804053d81ceSMarshall Clowbool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
805053d81ceSMarshall Clow                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
806053d81ceSMarshall Clow{
807053d81ceSMarshall Clow    return __lhs.compare(__rhs) > 0;
808053d81ceSMarshall Clow}
809053d81ceSMarshall Clow
810053d81ceSMarshall Clow
811053d81ceSMarshall Clow// operator <=
812053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
813053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
814053d81ceSMarshall Clowbool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
815053d81ceSMarshall Clow{
816053d81ceSMarshall Clow    return __lhs.compare(__rhs) <= 0;
817053d81ceSMarshall Clow}
818053d81ceSMarshall Clow
819053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
820053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
821053d81ceSMarshall Clowbool operator<=(basic_string_view<_CharT, _Traits> __lhs,
822053d81ceSMarshall Clow                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
823053d81ceSMarshall Clow{
824053d81ceSMarshall Clow    return __lhs.compare(__rhs) <= 0;
825053d81ceSMarshall Clow}
826053d81ceSMarshall Clow
827053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
828053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
829053d81ceSMarshall Clowbool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
830053d81ceSMarshall Clow                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
831053d81ceSMarshall Clow{
832053d81ceSMarshall Clow    return __lhs.compare(__rhs) <= 0;
833053d81ceSMarshall Clow}
834053d81ceSMarshall Clow
835053d81ceSMarshall Clow
836053d81ceSMarshall Clow// operator >=
837053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
838053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
839053d81ceSMarshall Clowbool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
840053d81ceSMarshall Clow{
841053d81ceSMarshall Clow    return __lhs.compare(__rhs) >= 0;
842053d81ceSMarshall Clow}
843053d81ceSMarshall Clow
844053d81ceSMarshall Clow
845053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
846053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
847053d81ceSMarshall Clowbool operator>=(basic_string_view<_CharT, _Traits> __lhs,
848053d81ceSMarshall Clow                typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
849053d81ceSMarshall Clow{
850053d81ceSMarshall Clow    return __lhs.compare(__rhs) >= 0;
851053d81ceSMarshall Clow}
852053d81ceSMarshall Clow
853053d81ceSMarshall Clowtemplate<class _CharT, class _Traits>
854053d81ceSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
855053d81ceSMarshall Clowbool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
856053d81ceSMarshall Clow                basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
857053d81ceSMarshall Clow{
858053d81ceSMarshall Clow    return __lhs.compare(__rhs) >= 0;
859053d81ceSMarshall Clow}
860053d81ceSMarshall Clow
861af4a29afSEric Fiselier
862af4a29afSEric Fiseliertemplate<class _CharT, class _Traits>
863af4a29afSEric Fiselierbasic_ostream<_CharT, _Traits>&
864af4a29afSEric Fiselieroperator<<(basic_ostream<_CharT, _Traits>& __os,
865af4a29afSEric Fiselier           basic_string_view<_CharT, _Traits> __str);
866af4a29afSEric Fiselier
867053d81ceSMarshall Clow// [string.view.hash]
86893184302SMarshall Clowtemplate<class _CharT>
86993184302SMarshall Clowstruct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > >
87093184302SMarshall Clow    : public unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t>
871053d81ceSMarshall Clow{
872a86710f1SLouis Dionne    _LIBCPP_INLINE_VISIBILITY
87393184302SMarshall Clow    size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT {
874053d81ceSMarshall Clow        return __do_string_hash(__val.data(), __val.data() + __val.size());
875053d81ceSMarshall Clow    }
876a86710f1SLouis Dionne};
877053d81ceSMarshall Clow
8788fd58a6bSMarshall Clow
8798fd58a6bSMarshall Clow#if _LIBCPP_STD_VER > 11
8808fd58a6bSMarshall Clowinline namespace literals
8818fd58a6bSMarshall Clow{
8828fd58a6bSMarshall Clow  inline namespace string_view_literals
8838fd58a6bSMarshall Clow  {
8848fd58a6bSMarshall Clow    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
88559b48302SMarshall Clow    basic_string_view<char> operator "" sv(const char *__str, size_t __len) _NOEXCEPT
8868fd58a6bSMarshall Clow    {
8878fd58a6bSMarshall Clow        return basic_string_view<char> (__str, __len);
8888fd58a6bSMarshall Clow    }
8898fd58a6bSMarshall Clow
890f4c1258dSLouis Dionne#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
8918fd58a6bSMarshall Clow    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
89259b48302SMarshall Clow    basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len) _NOEXCEPT
8938fd58a6bSMarshall Clow    {
8948fd58a6bSMarshall Clow        return basic_string_view<wchar_t> (__str, __len);
8958fd58a6bSMarshall Clow    }
896f4c1258dSLouis Dionne#endif
8978fd58a6bSMarshall Clow
8985c40c994SArthur O'Dwyer#ifndef _LIBCPP_HAS_NO_CHAR8_T
8997dad0bd6SMarshall Clow    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
9007dad0bd6SMarshall Clow    basic_string_view<char8_t> operator "" sv(const char8_t *__str, size_t __len) _NOEXCEPT
9017dad0bd6SMarshall Clow    {
9027dad0bd6SMarshall Clow        return basic_string_view<char8_t> (__str, __len);
9037dad0bd6SMarshall Clow    }
9047dad0bd6SMarshall Clow#endif
9057dad0bd6SMarshall Clow
9068fd58a6bSMarshall Clow    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
90759b48302SMarshall Clow    basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT
9088fd58a6bSMarshall Clow    {
9098fd58a6bSMarshall Clow        return basic_string_view<char16_t> (__str, __len);
9108fd58a6bSMarshall Clow    }
9118fd58a6bSMarshall Clow
9128fd58a6bSMarshall Clow    inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
91359b48302SMarshall Clow    basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len) _NOEXCEPT
9148fd58a6bSMarshall Clow    {
9158fd58a6bSMarshall Clow        return basic_string_view<char32_t> (__str, __len);
9168fd58a6bSMarshall Clow    }
9178fd58a6bSMarshall Clow  }
9188fd58a6bSMarshall Clow}
9198fd58a6bSMarshall Clow#endif
920053d81ceSMarshall Clow_LIBCPP_END_NAMESPACE_STD
921053d81ceSMarshall Clow
922a016efb1SEric Fiselier_LIBCPP_POP_MACROS
923a016efb1SEric Fiselier
924053d81ceSMarshall Clow#endif // _LIBCPP_STRING_VIEW
925