1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*- 2*58b9f456SAndroid Build Coastguard Worker//===------------------------ string_view ---------------------------------===// 3*58b9f456SAndroid Build Coastguard Worker// 4*58b9f456SAndroid Build Coastguard Worker// The LLVM Compiler Infrastructure 5*58b9f456SAndroid Build Coastguard Worker// 6*58b9f456SAndroid Build Coastguard Worker// This file is distributed under the University of Illinois Open Source 7*58b9f456SAndroid Build Coastguard Worker// License. See LICENSE.TXT for details. 8*58b9f456SAndroid Build Coastguard Worker// 9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===// 10*58b9f456SAndroid Build Coastguard Worker 11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_STRING_VIEW 12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_STRING_VIEW 13*58b9f456SAndroid Build Coastguard Worker 14*58b9f456SAndroid Build Coastguard Worker/* 15*58b9f456SAndroid Build Coastguard Workerstring_view synopsis 16*58b9f456SAndroid Build Coastguard Worker 17*58b9f456SAndroid Build Coastguard Workernamespace std { 18*58b9f456SAndroid Build Coastguard Worker 19*58b9f456SAndroid Build Coastguard Worker // 7.2, Class template basic_string_view 20*58b9f456SAndroid Build Coastguard Worker template<class charT, class traits = char_traits<charT>> 21*58b9f456SAndroid Build Coastguard Worker class basic_string_view; 22*58b9f456SAndroid Build Coastguard Worker 23*58b9f456SAndroid Build Coastguard Worker // 7.9, basic_string_view non-member comparison functions 24*58b9f456SAndroid Build Coastguard Worker template<class charT, class traits> 25*58b9f456SAndroid Build Coastguard Worker constexpr bool operator==(basic_string_view<charT, traits> x, 26*58b9f456SAndroid Build Coastguard Worker basic_string_view<charT, traits> y) noexcept; 27*58b9f456SAndroid Build Coastguard Worker template<class charT, class traits> 28*58b9f456SAndroid Build Coastguard Worker constexpr bool operator!=(basic_string_view<charT, traits> x, 29*58b9f456SAndroid Build Coastguard Worker basic_string_view<charT, traits> y) noexcept; 30*58b9f456SAndroid Build Coastguard Worker template<class charT, class traits> 31*58b9f456SAndroid Build Coastguard Worker constexpr bool operator< (basic_string_view<charT, traits> x, 32*58b9f456SAndroid Build Coastguard Worker basic_string_view<charT, traits> y) noexcept; 33*58b9f456SAndroid Build Coastguard Worker template<class charT, class traits> 34*58b9f456SAndroid Build Coastguard Worker constexpr bool operator> (basic_string_view<charT, traits> x, 35*58b9f456SAndroid Build Coastguard Worker basic_string_view<charT, traits> y) noexcept; 36*58b9f456SAndroid Build Coastguard Worker template<class charT, class traits> 37*58b9f456SAndroid Build Coastguard Worker constexpr bool operator<=(basic_string_view<charT, traits> x, 38*58b9f456SAndroid Build Coastguard Worker basic_string_view<charT, traits> y) noexcept; 39*58b9f456SAndroid Build Coastguard Worker template<class charT, class traits> 40*58b9f456SAndroid Build Coastguard Worker constexpr bool operator>=(basic_string_view<charT, traits> x, 41*58b9f456SAndroid Build Coastguard Worker basic_string_view<charT, traits> y) noexcept; 42*58b9f456SAndroid Build Coastguard Worker // see below, sufficient additional overloads of comparison functions 43*58b9f456SAndroid Build Coastguard Worker 44*58b9f456SAndroid Build Coastguard Worker // 7.10, Inserters and extractors 45*58b9f456SAndroid Build Coastguard Worker template<class charT, class traits> 46*58b9f456SAndroid Build Coastguard Worker basic_ostream<charT, traits>& 47*58b9f456SAndroid Build Coastguard Worker operator<<(basic_ostream<charT, traits>& os, 48*58b9f456SAndroid Build Coastguard Worker basic_string_view<charT, traits> str); 49*58b9f456SAndroid Build Coastguard Worker 50*58b9f456SAndroid Build Coastguard Worker // basic_string_view typedef names 51*58b9f456SAndroid Build Coastguard Worker typedef basic_string_view<char> string_view; 52*58b9f456SAndroid Build Coastguard Worker typedef basic_string_view<char16_t> u16string_view; 53*58b9f456SAndroid Build Coastguard Worker typedef basic_string_view<char32_t> u32string_view; 54*58b9f456SAndroid Build Coastguard Worker typedef basic_string_view<wchar_t> wstring_view; 55*58b9f456SAndroid Build Coastguard Worker 56*58b9f456SAndroid Build Coastguard Worker template<class charT, class traits = char_traits<charT>> 57*58b9f456SAndroid Build Coastguard Worker class basic_string_view { 58*58b9f456SAndroid Build Coastguard Worker public: 59*58b9f456SAndroid Build Coastguard Worker // types 60*58b9f456SAndroid Build Coastguard Worker typedef traits traits_type; 61*58b9f456SAndroid Build Coastguard Worker typedef charT value_type; 62*58b9f456SAndroid Build Coastguard Worker typedef charT* pointer; 63*58b9f456SAndroid Build Coastguard Worker typedef const charT* const_pointer; 64*58b9f456SAndroid Build Coastguard Worker typedef charT& reference; 65*58b9f456SAndroid Build Coastguard Worker typedef const charT& const_reference; 66*58b9f456SAndroid Build Coastguard Worker typedef implementation-defined const_iterator; 67*58b9f456SAndroid Build Coastguard Worker typedef const_iterator iterator; 68*58b9f456SAndroid Build Coastguard Worker typedef reverse_iterator<const_iterator> const_reverse_iterator; 69*58b9f456SAndroid Build Coastguard Worker typedef const_reverse_iterator reverse_iterator; 70*58b9f456SAndroid Build Coastguard Worker typedef size_t size_type; 71*58b9f456SAndroid Build Coastguard Worker typedef ptrdiff_t difference_type; 72*58b9f456SAndroid Build Coastguard Worker static constexpr size_type npos = size_type(-1); 73*58b9f456SAndroid Build Coastguard Worker 74*58b9f456SAndroid Build Coastguard Worker // 7.3, basic_string_view constructors and assignment operators 75*58b9f456SAndroid Build Coastguard Worker constexpr basic_string_view() noexcept; 76*58b9f456SAndroid Build Coastguard Worker constexpr basic_string_view(const basic_string_view&) noexcept = default; 77*58b9f456SAndroid Build Coastguard Worker basic_string_view& operator=(const basic_string_view&) noexcept = default; 78*58b9f456SAndroid Build Coastguard Worker template<class Allocator> 79*58b9f456SAndroid Build Coastguard Worker constexpr basic_string_view(const charT* str); 80*58b9f456SAndroid Build Coastguard Worker constexpr basic_string_view(const charT* str, size_type len); 81*58b9f456SAndroid Build Coastguard Worker 82*58b9f456SAndroid Build Coastguard Worker // 7.4, basic_string_view iterator support 83*58b9f456SAndroid Build Coastguard Worker constexpr const_iterator begin() const noexcept; 84*58b9f456SAndroid Build Coastguard Worker constexpr const_iterator end() const noexcept; 85*58b9f456SAndroid Build Coastguard Worker constexpr const_iterator cbegin() const noexcept; 86*58b9f456SAndroid Build Coastguard Worker constexpr const_iterator cend() const noexcept; 87*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rbegin() const noexcept; 88*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rend() const noexcept; 89*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crbegin() const noexcept; 90*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crend() const noexcept; 91*58b9f456SAndroid Build Coastguard Worker 92*58b9f456SAndroid Build Coastguard Worker // 7.5, basic_string_view capacity 93*58b9f456SAndroid Build Coastguard Worker constexpr size_type size() const noexcept; 94*58b9f456SAndroid Build Coastguard Worker constexpr size_type length() const noexcept; 95*58b9f456SAndroid Build Coastguard Worker constexpr size_type max_size() const noexcept; 96*58b9f456SAndroid Build Coastguard Worker constexpr bool empty() const noexcept; 97*58b9f456SAndroid Build Coastguard Worker 98*58b9f456SAndroid Build Coastguard Worker // 7.6, basic_string_view element access 99*58b9f456SAndroid Build Coastguard Worker constexpr const_reference operator[](size_type pos) const; 100*58b9f456SAndroid Build Coastguard Worker constexpr const_reference at(size_type pos) const; 101*58b9f456SAndroid Build Coastguard Worker constexpr const_reference front() const; 102*58b9f456SAndroid Build Coastguard Worker constexpr const_reference back() const; 103*58b9f456SAndroid Build Coastguard Worker constexpr const_pointer data() const noexcept; 104*58b9f456SAndroid Build Coastguard Worker 105*58b9f456SAndroid Build Coastguard Worker // 7.7, basic_string_view modifiers 106*58b9f456SAndroid Build Coastguard Worker constexpr void remove_prefix(size_type n); 107*58b9f456SAndroid Build Coastguard Worker constexpr void remove_suffix(size_type n); 108*58b9f456SAndroid Build Coastguard Worker constexpr void swap(basic_string_view& s) noexcept; 109*58b9f456SAndroid Build Coastguard Worker 110*58b9f456SAndroid Build Coastguard Worker size_type copy(charT* s, size_type n, size_type pos = 0) const; 111*58b9f456SAndroid Build Coastguard Worker 112*58b9f456SAndroid Build Coastguard Worker constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const; 113*58b9f456SAndroid Build Coastguard Worker constexpr int compare(basic_string_view s) const noexcept; 114*58b9f456SAndroid Build Coastguard Worker constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const; 115*58b9f456SAndroid Build Coastguard Worker constexpr int compare(size_type pos1, size_type n1, 116*58b9f456SAndroid Build Coastguard Worker basic_string_view s, size_type pos2, size_type n2) const; 117*58b9f456SAndroid Build Coastguard Worker constexpr int compare(const charT* s) const; 118*58b9f456SAndroid Build Coastguard Worker constexpr int compare(size_type pos1, size_type n1, const charT* s) const; 119*58b9f456SAndroid Build Coastguard Worker constexpr int compare(size_type pos1, size_type n1, 120*58b9f456SAndroid Build Coastguard Worker const charT* s, size_type n2) const; 121*58b9f456SAndroid Build Coastguard Worker constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept; 122*58b9f456SAndroid Build Coastguard Worker constexpr size_type find(charT c, size_type pos = 0) const noexcept; 123*58b9f456SAndroid Build Coastguard Worker constexpr size_type find(const charT* s, size_type pos, size_type n) const; 124*58b9f456SAndroid Build Coastguard Worker constexpr size_type find(const charT* s, size_type pos = 0) const; 125*58b9f456SAndroid Build Coastguard Worker constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept; 126*58b9f456SAndroid Build Coastguard Worker constexpr size_type rfind(charT c, size_type pos = npos) const noexcept; 127*58b9f456SAndroid Build Coastguard Worker constexpr size_type rfind(const charT* s, size_type pos, size_type n) const; 128*58b9f456SAndroid Build Coastguard Worker constexpr size_type rfind(const charT* s, size_type pos = npos) const; 129*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept; 130*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept; 131*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const; 132*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_first_of(const charT* s, size_type pos = 0) const; 133*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept; 134*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept; 135*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const; 136*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_last_of(const charT* s, size_type pos = npos) const; 137*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept; 138*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept; 139*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; 140*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const; 141*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept; 142*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept; 143*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const; 144*58b9f456SAndroid Build Coastguard Worker constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const; 145*58b9f456SAndroid Build Coastguard Worker 146*58b9f456SAndroid Build Coastguard Worker constexpr bool starts_with(basic_string_view s) const noexcept; // C++2a 147*58b9f456SAndroid Build Coastguard Worker constexpr bool starts_with(charT c) const noexcept; // C++2a 148*58b9f456SAndroid Build Coastguard Worker constexpr bool starts_with(const charT* s) const; // C++2a 149*58b9f456SAndroid Build Coastguard Worker constexpr bool ends_with(basic_string_view s) const noexcept; // C++2a 150*58b9f456SAndroid Build Coastguard Worker constexpr bool ends_with(charT c) const noexcept; // C++2a 151*58b9f456SAndroid Build Coastguard Worker constexpr bool ends_with(const charT* s) const; // C++2a 152*58b9f456SAndroid Build Coastguard Worker 153*58b9f456SAndroid Build Coastguard Worker private: 154*58b9f456SAndroid Build Coastguard Worker const_pointer data_; // exposition only 155*58b9f456SAndroid Build Coastguard Worker size_type size_; // exposition only 156*58b9f456SAndroid Build Coastguard Worker }; 157*58b9f456SAndroid Build Coastguard Worker 158*58b9f456SAndroid Build Coastguard Worker // 7.11, Hash support 159*58b9f456SAndroid Build Coastguard Worker template <class T> struct hash; 160*58b9f456SAndroid Build Coastguard Worker template <> struct hash<string_view>; 161*58b9f456SAndroid Build Coastguard Worker template <> struct hash<u16string_view>; 162*58b9f456SAndroid Build Coastguard Worker template <> struct hash<u32string_view>; 163*58b9f456SAndroid Build Coastguard Worker template <> struct hash<wstring_view>; 164*58b9f456SAndroid Build Coastguard Worker 165*58b9f456SAndroid Build Coastguard Worker constexpr basic_string_view<char> operator "" sv( const char *str, size_t len ) noexcept; 166*58b9f456SAndroid Build Coastguard Worker constexpr basic_string_view<wchar_t> operator "" sv( const wchar_t *str, size_t len ) noexcept; 167*58b9f456SAndroid Build Coastguard Worker constexpr basic_string_view<char16_t> operator "" sv( const char16_t *str, size_t len ) noexcept; 168*58b9f456SAndroid Build Coastguard Worker constexpr basic_string_view<char32_t> operator "" sv( const char32_t *str, size_t len ) noexcept; 169*58b9f456SAndroid Build Coastguard Worker 170*58b9f456SAndroid Build Coastguard Worker} // namespace std 171*58b9f456SAndroid Build Coastguard Worker 172*58b9f456SAndroid Build Coastguard Worker 173*58b9f456SAndroid Build Coastguard Worker*/ 174*58b9f456SAndroid Build Coastguard Worker 175*58b9f456SAndroid Build Coastguard Worker#include <__config> 176*58b9f456SAndroid Build Coastguard Worker#include <__string> 177*58b9f456SAndroid Build Coastguard Worker#include <algorithm> 178*58b9f456SAndroid Build Coastguard Worker#include <iterator> 179*58b9f456SAndroid Build Coastguard Worker#include <limits> 180*58b9f456SAndroid Build Coastguard Worker#include <stdexcept> 181*58b9f456SAndroid Build Coastguard Worker#include <version> 182*58b9f456SAndroid Build Coastguard Worker#include <__debug> 183*58b9f456SAndroid Build Coastguard Worker 184*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 185*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header 186*58b9f456SAndroid Build Coastguard Worker#endif 187*58b9f456SAndroid Build Coastguard Worker 188*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS 189*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros> 190*58b9f456SAndroid Build Coastguard Worker 191*58b9f456SAndroid Build Coastguard Worker 192*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD 193*58b9f456SAndroid Build Coastguard Worker 194*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits = char_traits<_CharT> > 195*58b9f456SAndroid Build Coastguard Workerclass _LIBCPP_TEMPLATE_VIS basic_string_view { 196*58b9f456SAndroid Build Coastguard Workerpublic: 197*58b9f456SAndroid Build Coastguard Worker // types 198*58b9f456SAndroid Build Coastguard Worker typedef _Traits traits_type; 199*58b9f456SAndroid Build Coastguard Worker typedef _CharT value_type; 200*58b9f456SAndroid Build Coastguard Worker typedef _CharT* pointer; 201*58b9f456SAndroid Build Coastguard Worker typedef const _CharT* const_pointer; 202*58b9f456SAndroid Build Coastguard Worker typedef _CharT& reference; 203*58b9f456SAndroid Build Coastguard Worker typedef const _CharT& const_reference; 204*58b9f456SAndroid Build Coastguard Worker typedef const_pointer const_iterator; // See [string.view.iterators] 205*58b9f456SAndroid Build Coastguard Worker typedef const_iterator iterator; 206*58b9f456SAndroid Build Coastguard Worker typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 207*58b9f456SAndroid Build Coastguard Worker typedef const_reverse_iterator reverse_iterator; 208*58b9f456SAndroid Build Coastguard Worker typedef size_t size_type; 209*58b9f456SAndroid Build Coastguard Worker typedef ptrdiff_t difference_type; 210*58b9f456SAndroid Build Coastguard Worker static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1); 211*58b9f456SAndroid Build Coastguard Worker 212*58b9f456SAndroid Build Coastguard Worker static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array"); 213*58b9f456SAndroid Build Coastguard Worker static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string_view must be standard-layout"); 214*58b9f456SAndroid Build Coastguard Worker static_assert(( is_trivial<value_type>::value), "Character type of basic_string_view must be trivial"); 215*58b9f456SAndroid Build Coastguard Worker static_assert((is_same<_CharT, typename traits_type::char_type>::value), 216*58b9f456SAndroid Build Coastguard Worker "traits_type::char_type must be the same type as CharT"); 217*58b9f456SAndroid Build Coastguard Worker 218*58b9f456SAndroid Build Coastguard Worker // [string.view.cons], construct/copy 219*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 220*58b9f456SAndroid Build Coastguard Worker basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {} 221*58b9f456SAndroid Build Coastguard Worker 222*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 223*58b9f456SAndroid Build Coastguard Worker basic_string_view(const basic_string_view&) _NOEXCEPT = default; 224*58b9f456SAndroid Build Coastguard Worker 225*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 226*58b9f456SAndroid Build Coastguard Worker basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default; 227*58b9f456SAndroid Build Coastguard Worker 228*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 229*58b9f456SAndroid Build Coastguard Worker basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT 230*58b9f456SAndroid Build Coastguard Worker : __data(__s), __size(__len) 231*58b9f456SAndroid Build Coastguard Worker { 232*58b9f456SAndroid Build Coastguard Worker// #if _LIBCPP_STD_VER > 11 233*58b9f456SAndroid Build Coastguard Worker// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr"); 234*58b9f456SAndroid Build Coastguard Worker// #endif 235*58b9f456SAndroid Build Coastguard Worker } 236*58b9f456SAndroid Build Coastguard Worker 237*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 238*58b9f456SAndroid Build Coastguard Worker basic_string_view(const _CharT* __s) 239*58b9f456SAndroid Build Coastguard Worker : __data(__s), __size(_Traits::length(__s)) {} 240*58b9f456SAndroid Build Coastguard Worker 241*58b9f456SAndroid Build Coastguard Worker // [string.view.iterators], iterators 242*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 243*58b9f456SAndroid Build Coastguard Worker const_iterator begin() const _NOEXCEPT { return cbegin(); } 244*58b9f456SAndroid Build Coastguard Worker 245*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 246*58b9f456SAndroid Build Coastguard Worker const_iterator end() const _NOEXCEPT { return cend(); } 247*58b9f456SAndroid Build Coastguard Worker 248*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 249*58b9f456SAndroid Build Coastguard Worker const_iterator cbegin() const _NOEXCEPT { return __data; } 250*58b9f456SAndroid Build Coastguard Worker 251*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 252*58b9f456SAndroid Build Coastguard Worker const_iterator cend() const _NOEXCEPT { return __data + __size; } 253*58b9f456SAndroid Build Coastguard Worker 254*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY 255*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } 256*58b9f456SAndroid Build Coastguard Worker 257*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY 258*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } 259*58b9f456SAndroid Build Coastguard Worker 260*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY 261*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } 262*58b9f456SAndroid Build Coastguard Worker 263*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY 264*58b9f456SAndroid Build Coastguard Worker const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } 265*58b9f456SAndroid Build Coastguard Worker 266*58b9f456SAndroid Build Coastguard Worker // [string.view.capacity], capacity 267*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 268*58b9f456SAndroid Build Coastguard Worker size_type size() const _NOEXCEPT { return __size; } 269*58b9f456SAndroid Build Coastguard Worker 270*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 271*58b9f456SAndroid Build Coastguard Worker size_type length() const _NOEXCEPT { return __size; } 272*58b9f456SAndroid Build Coastguard Worker 273*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 274*58b9f456SAndroid Build Coastguard Worker size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max(); } 275*58b9f456SAndroid Build Coastguard Worker 276*58b9f456SAndroid Build Coastguard Worker _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 277*58b9f456SAndroid Build Coastguard Worker bool empty() const _NOEXCEPT { return __size == 0; } 278*58b9f456SAndroid Build Coastguard Worker 279*58b9f456SAndroid Build Coastguard Worker // [string.view.access], element access 280*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 281*58b9f456SAndroid Build Coastguard Worker const_reference operator[](size_type __pos) const _NOEXCEPT { return __data[__pos]; } 282*58b9f456SAndroid Build Coastguard Worker 283*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 284*58b9f456SAndroid Build Coastguard Worker const_reference at(size_type __pos) const 285*58b9f456SAndroid Build Coastguard Worker { 286*58b9f456SAndroid Build Coastguard Worker return __pos >= size() 287*58b9f456SAndroid Build Coastguard Worker ? (__throw_out_of_range("string_view::at"), __data[0]) 288*58b9f456SAndroid Build Coastguard Worker : __data[__pos]; 289*58b9f456SAndroid Build Coastguard Worker } 290*58b9f456SAndroid Build Coastguard Worker 291*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 292*58b9f456SAndroid Build Coastguard Worker const_reference front() const 293*58b9f456SAndroid Build Coastguard Worker { 294*58b9f456SAndroid Build Coastguard Worker return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0]; 295*58b9f456SAndroid Build Coastguard Worker } 296*58b9f456SAndroid Build Coastguard Worker 297*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 298*58b9f456SAndroid Build Coastguard Worker const_reference back() const 299*58b9f456SAndroid Build Coastguard Worker { 300*58b9f456SAndroid Build Coastguard Worker return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1]; 301*58b9f456SAndroid Build Coastguard Worker } 302*58b9f456SAndroid Build Coastguard Worker 303*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 304*58b9f456SAndroid Build Coastguard Worker const_pointer data() const _NOEXCEPT { return __data; } 305*58b9f456SAndroid Build Coastguard Worker 306*58b9f456SAndroid Build Coastguard Worker // [string.view.modifiers], modifiers: 307*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 308*58b9f456SAndroid Build Coastguard Worker void remove_prefix(size_type __n) _NOEXCEPT 309*58b9f456SAndroid Build Coastguard Worker { 310*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()"); 311*58b9f456SAndroid Build Coastguard Worker __data += __n; 312*58b9f456SAndroid Build Coastguard Worker __size -= __n; 313*58b9f456SAndroid Build Coastguard Worker } 314*58b9f456SAndroid Build Coastguard Worker 315*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 316*58b9f456SAndroid Build Coastguard Worker void remove_suffix(size_type __n) _NOEXCEPT 317*58b9f456SAndroid Build Coastguard Worker { 318*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()"); 319*58b9f456SAndroid Build Coastguard Worker __size -= __n; 320*58b9f456SAndroid Build Coastguard Worker } 321*58b9f456SAndroid Build Coastguard Worker 322*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 323*58b9f456SAndroid Build Coastguard Worker void swap(basic_string_view& __other) _NOEXCEPT 324*58b9f456SAndroid Build Coastguard Worker { 325*58b9f456SAndroid Build Coastguard Worker const value_type *__p = __data; 326*58b9f456SAndroid Build Coastguard Worker __data = __other.__data; 327*58b9f456SAndroid Build Coastguard Worker __other.__data = __p; 328*58b9f456SAndroid Build Coastguard Worker 329*58b9f456SAndroid Build Coastguard Worker size_type __sz = __size; 330*58b9f456SAndroid Build Coastguard Worker __size = __other.__size; 331*58b9f456SAndroid Build Coastguard Worker __other.__size = __sz; 332*58b9f456SAndroid Build Coastguard Worker } 333*58b9f456SAndroid Build Coastguard Worker 334*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 335*58b9f456SAndroid Build Coastguard Worker size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const 336*58b9f456SAndroid Build Coastguard Worker { 337*58b9f456SAndroid Build Coastguard Worker if (__pos > size()) 338*58b9f456SAndroid Build Coastguard Worker __throw_out_of_range("string_view::copy"); 339*58b9f456SAndroid Build Coastguard Worker size_type __rlen = _VSTD::min(__n, size() - __pos); 340*58b9f456SAndroid Build Coastguard Worker _Traits::copy(__s, data() + __pos, __rlen); 341*58b9f456SAndroid Build Coastguard Worker return __rlen; 342*58b9f456SAndroid Build Coastguard Worker } 343*58b9f456SAndroid Build Coastguard Worker 344*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 345*58b9f456SAndroid Build Coastguard Worker basic_string_view substr(size_type __pos = 0, size_type __n = npos) const 346*58b9f456SAndroid Build Coastguard Worker { 347*58b9f456SAndroid Build Coastguard Worker return __pos > size() 348*58b9f456SAndroid Build Coastguard Worker ? (__throw_out_of_range("string_view::substr"), basic_string_view()) 349*58b9f456SAndroid Build Coastguard Worker : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos)); 350*58b9f456SAndroid Build Coastguard Worker } 351*58b9f456SAndroid Build Coastguard Worker 352*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT 353*58b9f456SAndroid Build Coastguard Worker { 354*58b9f456SAndroid Build Coastguard Worker size_type __rlen = _VSTD::min( size(), __sv.size()); 355*58b9f456SAndroid Build Coastguard Worker int __retval = _Traits::compare(data(), __sv.data(), __rlen); 356*58b9f456SAndroid Build Coastguard Worker if ( __retval == 0 ) // first __rlen chars matched 357*58b9f456SAndroid Build Coastguard Worker __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 ); 358*58b9f456SAndroid Build Coastguard Worker return __retval; 359*58b9f456SAndroid Build Coastguard Worker } 360*58b9f456SAndroid Build Coastguard Worker 361*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 362*58b9f456SAndroid Build Coastguard Worker int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const 363*58b9f456SAndroid Build Coastguard Worker { 364*58b9f456SAndroid Build Coastguard Worker return substr(__pos1, __n1).compare(__sv); 365*58b9f456SAndroid Build Coastguard Worker } 366*58b9f456SAndroid Build Coastguard Worker 367*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 368*58b9f456SAndroid Build Coastguard Worker int compare( size_type __pos1, size_type __n1, 369*58b9f456SAndroid Build Coastguard Worker basic_string_view __sv, size_type __pos2, size_type __n2) const 370*58b9f456SAndroid Build Coastguard Worker { 371*58b9f456SAndroid Build Coastguard Worker return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); 372*58b9f456SAndroid Build Coastguard Worker } 373*58b9f456SAndroid Build Coastguard Worker 374*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 375*58b9f456SAndroid Build Coastguard Worker int compare(const _CharT* __s) const _NOEXCEPT 376*58b9f456SAndroid Build Coastguard Worker { 377*58b9f456SAndroid Build Coastguard Worker return compare(basic_string_view(__s)); 378*58b9f456SAndroid Build Coastguard Worker } 379*58b9f456SAndroid Build Coastguard Worker 380*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 381*58b9f456SAndroid Build Coastguard Worker int compare(size_type __pos1, size_type __n1, const _CharT* __s) const 382*58b9f456SAndroid Build Coastguard Worker { 383*58b9f456SAndroid Build Coastguard Worker return substr(__pos1, __n1).compare(basic_string_view(__s)); 384*58b9f456SAndroid Build Coastguard Worker } 385*58b9f456SAndroid Build Coastguard Worker 386*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 387*58b9f456SAndroid Build Coastguard Worker int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const 388*58b9f456SAndroid Build Coastguard Worker { 389*58b9f456SAndroid Build Coastguard Worker return substr(__pos1, __n1).compare(basic_string_view(__s, __n2)); 390*58b9f456SAndroid Build Coastguard Worker } 391*58b9f456SAndroid Build Coastguard Worker 392*58b9f456SAndroid Build Coastguard Worker // find 393*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 394*58b9f456SAndroid Build Coastguard Worker size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT 395*58b9f456SAndroid Build Coastguard Worker { 396*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); 397*58b9f456SAndroid Build Coastguard Worker return __str_find<value_type, size_type, traits_type, npos> 398*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s.data(), __pos, __s.size()); 399*58b9f456SAndroid Build Coastguard Worker } 400*58b9f456SAndroid Build Coastguard Worker 401*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 402*58b9f456SAndroid Build Coastguard Worker size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT 403*58b9f456SAndroid Build Coastguard Worker { 404*58b9f456SAndroid Build Coastguard Worker return __str_find<value_type, size_type, traits_type, npos> 405*58b9f456SAndroid Build Coastguard Worker (data(), size(), __c, __pos); 406*58b9f456SAndroid Build Coastguard Worker } 407*58b9f456SAndroid Build Coastguard Worker 408*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 409*58b9f456SAndroid Build Coastguard Worker size_type find(const _CharT* __s, size_type __pos, size_type __n) const 410*58b9f456SAndroid Build Coastguard Worker { 411*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr"); 412*58b9f456SAndroid Build Coastguard Worker return __str_find<value_type, size_type, traits_type, npos> 413*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, __n); 414*58b9f456SAndroid Build Coastguard Worker } 415*58b9f456SAndroid Build Coastguard Worker 416*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 417*58b9f456SAndroid Build Coastguard Worker size_type find(const _CharT* __s, size_type __pos = 0) const 418*58b9f456SAndroid Build Coastguard Worker { 419*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr"); 420*58b9f456SAndroid Build Coastguard Worker return __str_find<value_type, size_type, traits_type, npos> 421*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, traits_type::length(__s)); 422*58b9f456SAndroid Build Coastguard Worker } 423*58b9f456SAndroid Build Coastguard Worker 424*58b9f456SAndroid Build Coastguard Worker // rfind 425*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 426*58b9f456SAndroid Build Coastguard Worker size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT 427*58b9f456SAndroid Build Coastguard Worker { 428*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); 429*58b9f456SAndroid Build Coastguard Worker return __str_rfind<value_type, size_type, traits_type, npos> 430*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s.data(), __pos, __s.size()); 431*58b9f456SAndroid Build Coastguard Worker } 432*58b9f456SAndroid Build Coastguard Worker 433*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 434*58b9f456SAndroid Build Coastguard Worker size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT 435*58b9f456SAndroid Build Coastguard Worker { 436*58b9f456SAndroid Build Coastguard Worker return __str_rfind<value_type, size_type, traits_type, npos> 437*58b9f456SAndroid Build Coastguard Worker (data(), size(), __c, __pos); 438*58b9f456SAndroid Build Coastguard Worker } 439*58b9f456SAndroid Build Coastguard Worker 440*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 441*58b9f456SAndroid Build Coastguard Worker size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const 442*58b9f456SAndroid Build Coastguard Worker { 443*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr"); 444*58b9f456SAndroid Build Coastguard Worker return __str_rfind<value_type, size_type, traits_type, npos> 445*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, __n); 446*58b9f456SAndroid Build Coastguard Worker } 447*58b9f456SAndroid Build Coastguard Worker 448*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 449*58b9f456SAndroid Build Coastguard Worker size_type rfind(const _CharT* __s, size_type __pos=npos) const 450*58b9f456SAndroid Build Coastguard Worker { 451*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr"); 452*58b9f456SAndroid Build Coastguard Worker return __str_rfind<value_type, size_type, traits_type, npos> 453*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, traits_type::length(__s)); 454*58b9f456SAndroid Build Coastguard Worker } 455*58b9f456SAndroid Build Coastguard Worker 456*58b9f456SAndroid Build Coastguard Worker // find_first_of 457*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 458*58b9f456SAndroid Build Coastguard Worker size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT 459*58b9f456SAndroid Build Coastguard Worker { 460*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr"); 461*58b9f456SAndroid Build Coastguard Worker return __str_find_first_of<value_type, size_type, traits_type, npos> 462*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s.data(), __pos, __s.size()); 463*58b9f456SAndroid Build Coastguard Worker } 464*58b9f456SAndroid Build Coastguard Worker 465*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 466*58b9f456SAndroid Build Coastguard Worker size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT 467*58b9f456SAndroid Build Coastguard Worker { return find(__c, __pos); } 468*58b9f456SAndroid Build Coastguard Worker 469*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 470*58b9f456SAndroid Build Coastguard Worker size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const 471*58b9f456SAndroid Build Coastguard Worker { 472*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr"); 473*58b9f456SAndroid Build Coastguard Worker return __str_find_first_of<value_type, size_type, traits_type, npos> 474*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, __n); 475*58b9f456SAndroid Build Coastguard Worker } 476*58b9f456SAndroid Build Coastguard Worker 477*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 478*58b9f456SAndroid Build Coastguard Worker size_type find_first_of(const _CharT* __s, size_type __pos=0) const 479*58b9f456SAndroid Build Coastguard Worker { 480*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr"); 481*58b9f456SAndroid Build Coastguard Worker return __str_find_first_of<value_type, size_type, traits_type, npos> 482*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, traits_type::length(__s)); 483*58b9f456SAndroid Build Coastguard Worker } 484*58b9f456SAndroid Build Coastguard Worker 485*58b9f456SAndroid Build Coastguard Worker // find_last_of 486*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 487*58b9f456SAndroid Build Coastguard Worker size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT 488*58b9f456SAndroid Build Coastguard Worker { 489*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr"); 490*58b9f456SAndroid Build Coastguard Worker return __str_find_last_of<value_type, size_type, traits_type, npos> 491*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s.data(), __pos, __s.size()); 492*58b9f456SAndroid Build Coastguard Worker } 493*58b9f456SAndroid Build Coastguard Worker 494*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 495*58b9f456SAndroid Build Coastguard Worker size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT 496*58b9f456SAndroid Build Coastguard Worker { return rfind(__c, __pos); } 497*58b9f456SAndroid Build Coastguard Worker 498*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 499*58b9f456SAndroid Build Coastguard Worker size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const 500*58b9f456SAndroid Build Coastguard Worker { 501*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr"); 502*58b9f456SAndroid Build Coastguard Worker return __str_find_last_of<value_type, size_type, traits_type, npos> 503*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, __n); 504*58b9f456SAndroid Build Coastguard Worker } 505*58b9f456SAndroid Build Coastguard Worker 506*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 507*58b9f456SAndroid Build Coastguard Worker size_type find_last_of(const _CharT* __s, size_type __pos=npos) const 508*58b9f456SAndroid Build Coastguard Worker { 509*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr"); 510*58b9f456SAndroid Build Coastguard Worker return __str_find_last_of<value_type, size_type, traits_type, npos> 511*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, traits_type::length(__s)); 512*58b9f456SAndroid Build Coastguard Worker } 513*58b9f456SAndroid Build Coastguard Worker 514*58b9f456SAndroid Build Coastguard Worker // find_first_not_of 515*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 516*58b9f456SAndroid Build Coastguard Worker size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT 517*58b9f456SAndroid Build Coastguard Worker { 518*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr"); 519*58b9f456SAndroid Build Coastguard Worker return __str_find_first_not_of<value_type, size_type, traits_type, npos> 520*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s.data(), __pos, __s.size()); 521*58b9f456SAndroid Build Coastguard Worker } 522*58b9f456SAndroid Build Coastguard Worker 523*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 524*58b9f456SAndroid Build Coastguard Worker size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT 525*58b9f456SAndroid Build Coastguard Worker { 526*58b9f456SAndroid Build Coastguard Worker return __str_find_first_not_of<value_type, size_type, traits_type, npos> 527*58b9f456SAndroid Build Coastguard Worker (data(), size(), __c, __pos); 528*58b9f456SAndroid Build Coastguard Worker } 529*58b9f456SAndroid Build Coastguard Worker 530*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 531*58b9f456SAndroid Build Coastguard Worker size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const 532*58b9f456SAndroid Build Coastguard Worker { 533*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr"); 534*58b9f456SAndroid Build Coastguard Worker return __str_find_first_not_of<value_type, size_type, traits_type, npos> 535*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, __n); 536*58b9f456SAndroid Build Coastguard Worker } 537*58b9f456SAndroid Build Coastguard Worker 538*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 539*58b9f456SAndroid Build Coastguard Worker size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const 540*58b9f456SAndroid Build Coastguard Worker { 541*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr"); 542*58b9f456SAndroid Build Coastguard Worker return __str_find_first_not_of<value_type, size_type, traits_type, npos> 543*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, traits_type::length(__s)); 544*58b9f456SAndroid Build Coastguard Worker } 545*58b9f456SAndroid Build Coastguard Worker 546*58b9f456SAndroid Build Coastguard Worker // find_last_not_of 547*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 548*58b9f456SAndroid Build Coastguard Worker size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT 549*58b9f456SAndroid Build Coastguard Worker { 550*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr"); 551*58b9f456SAndroid Build Coastguard Worker return __str_find_last_not_of<value_type, size_type, traits_type, npos> 552*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s.data(), __pos, __s.size()); 553*58b9f456SAndroid Build Coastguard Worker } 554*58b9f456SAndroid Build Coastguard Worker 555*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 556*58b9f456SAndroid Build Coastguard Worker size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT 557*58b9f456SAndroid Build Coastguard Worker { 558*58b9f456SAndroid Build Coastguard Worker return __str_find_last_not_of<value_type, size_type, traits_type, npos> 559*58b9f456SAndroid Build Coastguard Worker (data(), size(), __c, __pos); 560*58b9f456SAndroid Build Coastguard Worker } 561*58b9f456SAndroid Build Coastguard Worker 562*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 563*58b9f456SAndroid Build Coastguard Worker size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const 564*58b9f456SAndroid Build Coastguard Worker { 565*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr"); 566*58b9f456SAndroid Build Coastguard Worker return __str_find_last_not_of<value_type, size_type, traits_type, npos> 567*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, __n); 568*58b9f456SAndroid Build Coastguard Worker } 569*58b9f456SAndroid Build Coastguard Worker 570*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 571*58b9f456SAndroid Build Coastguard Worker size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const 572*58b9f456SAndroid Build Coastguard Worker { 573*58b9f456SAndroid Build Coastguard Worker _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr"); 574*58b9f456SAndroid Build Coastguard Worker return __str_find_last_not_of<value_type, size_type, traits_type, npos> 575*58b9f456SAndroid Build Coastguard Worker (data(), size(), __s, __pos, traits_type::length(__s)); 576*58b9f456SAndroid Build Coastguard Worker } 577*58b9f456SAndroid Build Coastguard Worker 578*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 17 579*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 580*58b9f456SAndroid Build Coastguard Worker bool starts_with(basic_string_view __s) const _NOEXCEPT 581*58b9f456SAndroid Build Coastguard Worker { return size() >= __s.size() && compare(0, __s.size(), __s) == 0; } 582*58b9f456SAndroid Build Coastguard Worker 583*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 584*58b9f456SAndroid Build Coastguard Worker bool starts_with(value_type __c) const _NOEXCEPT 585*58b9f456SAndroid Build Coastguard Worker { return !empty() && _Traits::eq(front(), __c); } 586*58b9f456SAndroid Build Coastguard Worker 587*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 588*58b9f456SAndroid Build Coastguard Worker bool starts_with(const value_type* __s) const _NOEXCEPT 589*58b9f456SAndroid Build Coastguard Worker { return starts_with(basic_string_view(__s)); } 590*58b9f456SAndroid Build Coastguard Worker 591*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 592*58b9f456SAndroid Build Coastguard Worker bool ends_with(basic_string_view __s) const _NOEXCEPT 593*58b9f456SAndroid Build Coastguard Worker { return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; } 594*58b9f456SAndroid Build Coastguard Worker 595*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 596*58b9f456SAndroid Build Coastguard Worker bool ends_with(value_type __c) const _NOEXCEPT 597*58b9f456SAndroid Build Coastguard Worker { return !empty() && _Traits::eq(back(), __c); } 598*58b9f456SAndroid Build Coastguard Worker 599*58b9f456SAndroid Build Coastguard Worker _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 600*58b9f456SAndroid Build Coastguard Worker bool ends_with(const value_type* __s) const _NOEXCEPT 601*58b9f456SAndroid Build Coastguard Worker { return ends_with(basic_string_view(__s)); } 602*58b9f456SAndroid Build Coastguard Worker#endif 603*58b9f456SAndroid Build Coastguard Worker 604*58b9f456SAndroid Build Coastguard Workerprivate: 605*58b9f456SAndroid Build Coastguard Worker const value_type* __data; 606*58b9f456SAndroid Build Coastguard Worker size_type __size; 607*58b9f456SAndroid Build Coastguard Worker}; 608*58b9f456SAndroid Build Coastguard Worker 609*58b9f456SAndroid Build Coastguard Worker 610*58b9f456SAndroid Build Coastguard Worker// [string.view.comparison] 611*58b9f456SAndroid Build Coastguard Worker// operator == 612*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 613*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 614*58b9f456SAndroid Build Coastguard Workerbool operator==(basic_string_view<_CharT, _Traits> __lhs, 615*58b9f456SAndroid Build Coastguard Worker basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 616*58b9f456SAndroid Build Coastguard Worker{ 617*58b9f456SAndroid Build Coastguard Worker if ( __lhs.size() != __rhs.size()) return false; 618*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) == 0; 619*58b9f456SAndroid Build Coastguard Worker} 620*58b9f456SAndroid Build Coastguard Worker 621*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 622*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 623*58b9f456SAndroid Build Coastguard Workerbool operator==(basic_string_view<_CharT, _Traits> __lhs, 624*58b9f456SAndroid Build Coastguard Worker typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 625*58b9f456SAndroid Build Coastguard Worker{ 626*58b9f456SAndroid Build Coastguard Worker if ( __lhs.size() != __rhs.size()) return false; 627*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) == 0; 628*58b9f456SAndroid Build Coastguard Worker} 629*58b9f456SAndroid Build Coastguard Worker 630*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 631*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 632*58b9f456SAndroid Build Coastguard Workerbool operator==(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 633*58b9f456SAndroid Build Coastguard Worker basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 634*58b9f456SAndroid Build Coastguard Worker{ 635*58b9f456SAndroid Build Coastguard Worker if ( __lhs.size() != __rhs.size()) return false; 636*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) == 0; 637*58b9f456SAndroid Build Coastguard Worker} 638*58b9f456SAndroid Build Coastguard Worker 639*58b9f456SAndroid Build Coastguard Worker 640*58b9f456SAndroid Build Coastguard Worker// operator != 641*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 642*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 643*58b9f456SAndroid Build Coastguard Workerbool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 644*58b9f456SAndroid Build Coastguard Worker{ 645*58b9f456SAndroid Build Coastguard Worker if ( __lhs.size() != __rhs.size()) 646*58b9f456SAndroid Build Coastguard Worker return true; 647*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) != 0; 648*58b9f456SAndroid Build Coastguard Worker} 649*58b9f456SAndroid Build Coastguard Worker 650*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 651*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 652*58b9f456SAndroid Build Coastguard Workerbool operator!=(basic_string_view<_CharT, _Traits> __lhs, 653*58b9f456SAndroid Build Coastguard Worker typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 654*58b9f456SAndroid Build Coastguard Worker{ 655*58b9f456SAndroid Build Coastguard Worker if ( __lhs.size() != __rhs.size()) 656*58b9f456SAndroid Build Coastguard Worker return true; 657*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) != 0; 658*58b9f456SAndroid Build Coastguard Worker} 659*58b9f456SAndroid Build Coastguard Worker 660*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 661*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 662*58b9f456SAndroid Build Coastguard Workerbool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 663*58b9f456SAndroid Build Coastguard Worker basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 664*58b9f456SAndroid Build Coastguard Worker{ 665*58b9f456SAndroid Build Coastguard Worker if ( __lhs.size() != __rhs.size()) 666*58b9f456SAndroid Build Coastguard Worker return true; 667*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) != 0; 668*58b9f456SAndroid Build Coastguard Worker} 669*58b9f456SAndroid Build Coastguard Worker 670*58b9f456SAndroid Build Coastguard Worker 671*58b9f456SAndroid Build Coastguard Worker// operator < 672*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 673*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 674*58b9f456SAndroid Build Coastguard Workerbool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 675*58b9f456SAndroid Build Coastguard Worker{ 676*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) < 0; 677*58b9f456SAndroid Build Coastguard Worker} 678*58b9f456SAndroid Build Coastguard Worker 679*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 680*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 681*58b9f456SAndroid Build Coastguard Workerbool operator<(basic_string_view<_CharT, _Traits> __lhs, 682*58b9f456SAndroid Build Coastguard Worker typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 683*58b9f456SAndroid Build Coastguard Worker{ 684*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) < 0; 685*58b9f456SAndroid Build Coastguard Worker} 686*58b9f456SAndroid Build Coastguard Worker 687*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 688*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 689*58b9f456SAndroid Build Coastguard Workerbool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 690*58b9f456SAndroid Build Coastguard Worker basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 691*58b9f456SAndroid Build Coastguard Worker{ 692*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) < 0; 693*58b9f456SAndroid Build Coastguard Worker} 694*58b9f456SAndroid Build Coastguard Worker 695*58b9f456SAndroid Build Coastguard Worker 696*58b9f456SAndroid Build Coastguard Worker// operator > 697*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 698*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 699*58b9f456SAndroid Build Coastguard Workerbool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 700*58b9f456SAndroid Build Coastguard Worker{ 701*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) > 0; 702*58b9f456SAndroid Build Coastguard Worker} 703*58b9f456SAndroid Build Coastguard Worker 704*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 705*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 706*58b9f456SAndroid Build Coastguard Workerbool operator>(basic_string_view<_CharT, _Traits> __lhs, 707*58b9f456SAndroid Build Coastguard Worker typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 708*58b9f456SAndroid Build Coastguard Worker{ 709*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) > 0; 710*58b9f456SAndroid Build Coastguard Worker} 711*58b9f456SAndroid Build Coastguard Worker 712*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 713*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 714*58b9f456SAndroid Build Coastguard Workerbool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 715*58b9f456SAndroid Build Coastguard Worker basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 716*58b9f456SAndroid Build Coastguard Worker{ 717*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) > 0; 718*58b9f456SAndroid Build Coastguard Worker} 719*58b9f456SAndroid Build Coastguard Worker 720*58b9f456SAndroid Build Coastguard Worker 721*58b9f456SAndroid Build Coastguard Worker// operator <= 722*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 723*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 724*58b9f456SAndroid Build Coastguard Workerbool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 725*58b9f456SAndroid Build Coastguard Worker{ 726*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) <= 0; 727*58b9f456SAndroid Build Coastguard Worker} 728*58b9f456SAndroid Build Coastguard Worker 729*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 730*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 731*58b9f456SAndroid Build Coastguard Workerbool operator<=(basic_string_view<_CharT, _Traits> __lhs, 732*58b9f456SAndroid Build Coastguard Worker typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 733*58b9f456SAndroid Build Coastguard Worker{ 734*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) <= 0; 735*58b9f456SAndroid Build Coastguard Worker} 736*58b9f456SAndroid Build Coastguard Worker 737*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 738*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 739*58b9f456SAndroid Build Coastguard Workerbool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 740*58b9f456SAndroid Build Coastguard Worker basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 741*58b9f456SAndroid Build Coastguard Worker{ 742*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) <= 0; 743*58b9f456SAndroid Build Coastguard Worker} 744*58b9f456SAndroid Build Coastguard Worker 745*58b9f456SAndroid Build Coastguard Worker 746*58b9f456SAndroid Build Coastguard Worker// operator >= 747*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 748*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 749*58b9f456SAndroid Build Coastguard Workerbool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 750*58b9f456SAndroid Build Coastguard Worker{ 751*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) >= 0; 752*58b9f456SAndroid Build Coastguard Worker} 753*58b9f456SAndroid Build Coastguard Worker 754*58b9f456SAndroid Build Coastguard Worker 755*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 756*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 757*58b9f456SAndroid Build Coastguard Workerbool operator>=(basic_string_view<_CharT, _Traits> __lhs, 758*58b9f456SAndroid Build Coastguard Worker typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 759*58b9f456SAndroid Build Coastguard Worker{ 760*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) >= 0; 761*58b9f456SAndroid Build Coastguard Worker} 762*58b9f456SAndroid Build Coastguard Worker 763*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 764*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 765*58b9f456SAndroid Build Coastguard Workerbool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 766*58b9f456SAndroid Build Coastguard Worker basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 767*58b9f456SAndroid Build Coastguard Worker{ 768*58b9f456SAndroid Build Coastguard Worker return __lhs.compare(__rhs) >= 0; 769*58b9f456SAndroid Build Coastguard Worker} 770*58b9f456SAndroid Build Coastguard Worker 771*58b9f456SAndroid Build Coastguard Workertypedef basic_string_view<char> string_view; 772*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_HAS_CHAR8_T 773*58b9f456SAndroid Build Coastguard Workertypedef basic_string_view<char8_t> u8string_view; 774*58b9f456SAndroid Build Coastguard Worker#endif 775*58b9f456SAndroid Build Coastguard Workertypedef basic_string_view<char16_t> u16string_view; 776*58b9f456SAndroid Build Coastguard Workertypedef basic_string_view<char32_t> u32string_view; 777*58b9f456SAndroid Build Coastguard Workertypedef basic_string_view<wchar_t> wstring_view; 778*58b9f456SAndroid Build Coastguard Worker 779*58b9f456SAndroid Build Coastguard Worker// [string.view.hash] 780*58b9f456SAndroid Build Coastguard Workertemplate<class _CharT, class _Traits> 781*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, _Traits> > 782*58b9f456SAndroid Build Coastguard Worker : public unary_function<basic_string_view<_CharT, _Traits>, size_t> 783*58b9f456SAndroid Build Coastguard Worker{ 784*58b9f456SAndroid Build Coastguard Worker _LIBCPP_INLINE_VISIBILITY 785*58b9f456SAndroid Build Coastguard Worker size_t operator()(const basic_string_view<_CharT, _Traits> __val) const _NOEXCEPT { 786*58b9f456SAndroid Build Coastguard Worker return __do_string_hash(__val.data(), __val.data() + __val.size()); 787*58b9f456SAndroid Build Coastguard Worker } 788*58b9f456SAndroid Build Coastguard Worker}; 789*58b9f456SAndroid Build Coastguard Worker 790*58b9f456SAndroid Build Coastguard Worker 791*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 11 792*58b9f456SAndroid Build Coastguard Workerinline namespace literals 793*58b9f456SAndroid Build Coastguard Worker{ 794*58b9f456SAndroid Build Coastguard Worker inline namespace string_view_literals 795*58b9f456SAndroid Build Coastguard Worker { 796*58b9f456SAndroid Build Coastguard Worker inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 797*58b9f456SAndroid Build Coastguard Worker basic_string_view<char> operator "" sv(const char *__str, size_t __len) _NOEXCEPT 798*58b9f456SAndroid Build Coastguard Worker { 799*58b9f456SAndroid Build Coastguard Worker return basic_string_view<char> (__str, __len); 800*58b9f456SAndroid Build Coastguard Worker } 801*58b9f456SAndroid Build Coastguard Worker 802*58b9f456SAndroid Build Coastguard Worker inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 803*58b9f456SAndroid Build Coastguard Worker basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len) _NOEXCEPT 804*58b9f456SAndroid Build Coastguard Worker { 805*58b9f456SAndroid Build Coastguard Worker return basic_string_view<wchar_t> (__str, __len); 806*58b9f456SAndroid Build Coastguard Worker } 807*58b9f456SAndroid Build Coastguard Worker 808*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_NO_HAS_CHAR8_T 809*58b9f456SAndroid Build Coastguard Worker inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 810*58b9f456SAndroid Build Coastguard Worker basic_string_view<char8_t> operator "" sv(const char8_t *__str, size_t __len) _NOEXCEPT 811*58b9f456SAndroid Build Coastguard Worker { 812*58b9f456SAndroid Build Coastguard Worker return basic_string_view<char8_t> (__str, __len); 813*58b9f456SAndroid Build Coastguard Worker } 814*58b9f456SAndroid Build Coastguard Worker#endif 815*58b9f456SAndroid Build Coastguard Worker 816*58b9f456SAndroid Build Coastguard Worker inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 817*58b9f456SAndroid Build Coastguard Worker basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT 818*58b9f456SAndroid Build Coastguard Worker { 819*58b9f456SAndroid Build Coastguard Worker return basic_string_view<char16_t> (__str, __len); 820*58b9f456SAndroid Build Coastguard Worker } 821*58b9f456SAndroid Build Coastguard Worker 822*58b9f456SAndroid Build Coastguard Worker inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 823*58b9f456SAndroid Build Coastguard Worker basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len) _NOEXCEPT 824*58b9f456SAndroid Build Coastguard Worker { 825*58b9f456SAndroid Build Coastguard Worker return basic_string_view<char32_t> (__str, __len); 826*58b9f456SAndroid Build Coastguard Worker } 827*58b9f456SAndroid Build Coastguard Worker } 828*58b9f456SAndroid Build Coastguard Worker} 829*58b9f456SAndroid Build Coastguard Worker#endif 830*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD 831*58b9f456SAndroid Build Coastguard Worker 832*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS 833*58b9f456SAndroid Build Coastguard Worker 834*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_STRING_VIEW 835