string_view revision 276792
126997Sgibbs// -*- C++ -*- 226997Sgibbs//===------------------------ string_view ---------------------------------===// 313177Sgibbs// 426997Sgibbs// The LLVM Compiler Infrastructure 526997Sgibbs// 613177Sgibbs// This file is distributed under the University of Illinois Open Source 726997Sgibbs// License. See LICENSE.TXT for details. 826997Sgibbs// 926997Sgibbs//===----------------------------------------------------------------------===// 1026997Sgibbs 1126997Sgibbs#ifndef _LIBCPP_LFTS_STRING_VIEW 1226997Sgibbs#define _LIBCPP_LFTS_STRING_VIEW 1326997Sgibbs 1426997Sgibbs/* 1526997Sgibbsstring_view synopsis 1626997Sgibbs 1726997Sgibbsnamespace std { 1813177Sgibbs namespace experimental { 1926997Sgibbs inline namespace library_fundamentals_v1 { 2026997Sgibbs 2126997Sgibbs // 7.2, Class template basic_string_view 2226997Sgibbs template<class charT, class traits = char_traits<charT>> 2326997Sgibbs class basic_string_view; 2426997Sgibbs 2513177Sgibbs // 7.9, basic_string_view non-member comparison functions 2626997Sgibbs template<class charT, class traits> 2726997Sgibbs constexpr bool operator==(basic_string_view<charT, traits> x, 2826997Sgibbs basic_string_view<charT, traits> y) noexcept; 2926997Sgibbs template<class charT, class traits> 3026997Sgibbs constexpr bool operator!=(basic_string_view<charT, traits> x, 3126997Sgibbs basic_string_view<charT, traits> y) noexcept; 3226997Sgibbs template<class charT, class traits> 3326997Sgibbs constexpr bool operator< (basic_string_view<charT, traits> x, 3426997Sgibbs basic_string_view<charT, traits> y) noexcept; 3526997Sgibbs template<class charT, class traits> 3626997Sgibbs constexpr bool operator> (basic_string_view<charT, traits> x, 3713177Sgibbs basic_string_view<charT, traits> y) noexcept; 3828169Sgibbs template<class charT, class traits> 3926997Sgibbs constexpr bool operator<=(basic_string_view<charT, traits> x, 404568Sgibbs basic_string_view<charT, traits> y) noexcept; 4123925Sgibbs template<class charT, class traits> 4223925Sgibbs constexpr bool operator>=(basic_string_view<charT, traits> x, 435647Sgibbs basic_string_view<charT, traits> y) noexcept; 4413177Sgibbs // see below, sufficient additional overloads of comparison functions 4519164Sgibbs 4619164Sgibbs // 7.10, Inserters and extractors 4713690Sgibbs template<class charT, class traits> 4813690Sgibbs basic_ostream<charT, traits>& 4913690Sgibbs operator<<(basic_ostream<charT, traits>& os, 5013690Sgibbs basic_string_view<charT, traits> str); 5113690Sgibbs 5213690Sgibbs // basic_string_view typedef names 5313690Sgibbs typedef basic_string_view<char> string_view; 5413690Sgibbs typedef basic_string_view<char16_t> u16string_view; 5519164Sgibbs typedef basic_string_view<char32_t> u32string_view; 5619164Sgibbs typedef basic_string_view<wchar_t> wstring_view; 5719164Sgibbs 5819164Sgibbs template<class charT, class traits = char_traits<charT>> 5919164Sgibbs class basic_string_view { 6013177Sgibbs public: 614568Sgibbs // types 6213177Sgibbs typedef traits traits_type; 6314449Sgibbs typedef charT value_type; 6414449Sgibbs typedef charT* pointer; 6513177Sgibbs typedef const charT* const_pointer; 6614449Sgibbs typedef charT& reference; 6723925Sgibbs typedef const charT& const_reference; 6823925Sgibbs typedef implementation-defined const_iterator; 6923925Sgibbs typedef const_iterator iterator; 7023925Sgibbs typedef reverse_iterator<const_iterator> const_reverse_iterator; 718104Sgibbs typedef const_reverse_iterator reverse_iterator; 7224662Sgibbs typedef size_t size_type; 7324662Sgibbs typedef ptrdiff_t difference_type; 7423925Sgibbs static constexpr size_type npos = size_type(-1); 7523925Sgibbs 7613177Sgibbs // 7.3, basic_string_view constructors and assignment operators 7723925Sgibbs constexpr basic_string_view() noexcept; 7823925Sgibbs constexpr basic_string_view(const basic_string_view&) noexcept = default; 7923925Sgibbs basic_string_view& operator=(const basic_string_view&) noexcept = default; 8023925Sgibbs template<class Allocator> 8113177Sgibbs basic_string_view(const basic_string<charT, traits, Allocator>& str) noexcept; 8223925Sgibbs constexpr basic_string_view(const charT* str); 8324662Sgibbs constexpr basic_string_view(const charT* str, size_type len); 8424662Sgibbs 8523925Sgibbs // 7.4, basic_string_view iterator support 8623925Sgibbs constexpr const_iterator begin() const noexcept; 8723925Sgibbs constexpr const_iterator end() const noexcept; 8823925Sgibbs constexpr const_iterator cbegin() const noexcept; 8919164Sgibbs constexpr const_iterator cend() const noexcept; 9019164Sgibbs const_reverse_iterator rbegin() const noexcept; 9123925Sgibbs const_reverse_iterator rend() const noexcept; 9223925Sgibbs const_reverse_iterator crbegin() const noexcept; 934568Sgibbs const_reverse_iterator crend() const noexcept; 9413690Sgibbs 9513690Sgibbs // 7.5, basic_string_view capacity 9619164Sgibbs constexpr size_type size() const noexcept; 9723925Sgibbs constexpr size_type length() const noexcept; 9819164Sgibbs constexpr size_type max_size() const noexcept; 9913177Sgibbs constexpr bool empty() const noexcept; 10023925Sgibbs 10123925Sgibbs // 7.6, basic_string_view element access 10223925Sgibbs constexpr const_reference operator[](size_type pos) const; 10323925Sgibbs constexpr const_reference at(size_type pos) const; 10419164Sgibbs constexpr const_reference front() const; 10523925Sgibbs constexpr const_reference back() const; 10623925Sgibbs constexpr const_pointer data() const noexcept; 10719164Sgibbs 10823925Sgibbs // 7.7, basic_string_view modifiers 10923925Sgibbs constexpr void clear() noexcept; 11019164Sgibbs constexpr void remove_prefix(size_type n); 11119164Sgibbs constexpr void remove_suffix(size_type n); 11219164Sgibbs constexpr void swap(basic_string_view& s) noexcept; 11319164Sgibbs 11423925Sgibbs // 7.8, basic_string_view string operations 11523925Sgibbs template<class Allocator> 1164568Sgibbs explicit operator basic_string<charT, traits, Allocator>() const; 11713177Sgibbs template<class Allocator = allocator<charT>> 11813177Sgibbs basic_string<charT, traits, Allocator> to_string( 11913177Sgibbs const Allocator& a = Allocator()) const; 12013177Sgibbs 12113177Sgibbs size_type copy(charT* s, size_type n, size_type pos = 0) const; 12219921Sgibbs 12319164Sgibbs constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const; 12419164Sgibbs constexpr int compare(basic_string_view s) const noexcept; 12513177Sgibbs constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const; 1265647Sgibbs constexpr int compare(size_type pos1, size_type n1, 12723925Sgibbs basic_string_view s, size_type pos2, size_type n2) const; 12823925Sgibbs constexpr int compare(const charT* s) const; 12923925Sgibbs constexpr int compare(size_type pos1, size_type n1, const charT* s) const; 13023925Sgibbs constexpr int compare(size_type pos1, size_type n1, 13123925Sgibbs const charT* s, size_type n2) const; 13219164Sgibbs constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept; 13319164Sgibbs constexpr size_type find(charT c, size_type pos = 0) const noexcept; 13419164Sgibbs constexpr size_type find(const charT* s, size_type pos, size_type n) const; 13519164Sgibbs constexpr size_type find(const charT* s, size_type pos = 0) const; 13619164Sgibbs constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept; 13723925Sgibbs constexpr size_type rfind(charT c, size_type pos = npos) const noexcept; 13823925Sgibbs constexpr size_type rfind(const charT* s, size_type pos, size_type n) const; 13919164Sgibbs constexpr size_type rfind(const charT* s, size_type pos = npos) const; 14019164Sgibbs constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept; 14119164Sgibbs constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept; 14219164Sgibbs constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const; 14319164Sgibbs constexpr size_type find_first_of(const charT* s, size_type pos = 0) const; 14423925Sgibbs constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept; 14523925Sgibbs constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept; 14619164Sgibbs constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const; 14723925Sgibbs constexpr size_type find_last_of(const charT* s, size_type pos = npos) const; 14819218Sgibbs constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept; 14919218Sgibbs constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept; 15021947Sgibbs constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; 15119218Sgibbs constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const; 15223925Sgibbs constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept; 15323925Sgibbs constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept; 15419218Sgibbs constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const; 15519164Sgibbs constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const; 15623925Sgibbs 15719164Sgibbs private: 15823925Sgibbs const_pointer data_; // exposition only 15923925Sgibbs size_type size_; // exposition only 16023925Sgibbs }; 16125005Sgibbs 16219164Sgibbs } // namespace fundamentals_v1 16323925Sgibbs } // namespace experimental 16423925Sgibbs 16523925Sgibbs // 7.11, Hash support 16623925Sgibbs template <class T> struct hash; 16725005Sgibbs template <> struct hash<experimental::string_view>; 16819164Sgibbs template <> struct hash<experimental::u16string_view>; 16923925Sgibbs template <> struct hash<experimental::u32string_view>; 17023925Sgibbs template <> struct hash<experimental::wstring_view>; 17123925Sgibbs 1724568Sgibbs} // namespace std 1735326Sgibbs 17419164Sgibbs 17519164Sgibbs*/ 17619164Sgibbs 17719164Sgibbs#include <experimental/__config> 17823925Sgibbs 17923925Sgibbs#include <string> 18023925Sgibbs#include <algorithm> 18123925Sgibbs#include <iterator> 18223925Sgibbs#include <ostream> 18323925Sgibbs#include <iomanip> 18423925Sgibbs 18523925Sgibbs#include <__debug> 18623925Sgibbs 18723925Sgibbs#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 18823925Sgibbs#pragma GCC system_header 1898104Sgibbs#endif 19023925Sgibbs 19123991Sgibbs_LIBCPP_BEGIN_NAMESPACE_LFTS 19223925Sgibbs 19323925Sgibbs template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> > 19423925Sgibbs class _LIBCPP_TYPE_VIS_ONLY basic_string_view { 19523925Sgibbs public: 19623991Sgibbs // types 19723925Sgibbs typedef _Traits traits_type; 19823925Sgibbs typedef _CharT value_type; 19923925Sgibbs typedef const _CharT* pointer; 20023925Sgibbs typedef const _CharT* const_pointer; 20123925Sgibbs typedef const _CharT& reference; 20213177Sgibbs typedef const _CharT& const_reference; 20323925Sgibbs typedef const_pointer const_iterator; // See [string.view.iterators] 20423925Sgibbs typedef const_iterator iterator; 20513177Sgibbs typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 20623925Sgibbs typedef const_reverse_iterator reverse_iterator; 20723925Sgibbs typedef size_t size_type; 20823925Sgibbs typedef ptrdiff_t difference_type; 20923925Sgibbs static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1); 21023925Sgibbs 21123925Sgibbs // [string.view.cons], construct/copy 21223925Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 2134568Sgibbs basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {} 21413177Sgibbs 21523925Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 21623925Sgibbs basic_string_view(const basic_string_view&) _NOEXCEPT = default; 21723925Sgibbs 21823925Sgibbs _LIBCPP_INLINE_VISIBILITY 21923925Sgibbs basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default; 22023925Sgibbs 22125005Sgibbs template<class _Allocator> 22223925Sgibbs _LIBCPP_INLINE_VISIBILITY 22323925Sgibbs basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& __str) _NOEXCEPT 22423925Sgibbs : __data (__str.data()), __size(__str.size()) {} 22523925Sgibbs 22625005Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 22725005Sgibbs basic_string_view(const _CharT* __s, size_type __len) 22824914Sgibbs : __data(__s), __size(__len) 22923925Sgibbs { 23023925Sgibbs// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): recieved nullptr"); 23113177Sgibbs } 23213177Sgibbs 23313177Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 23413177Sgibbs basic_string_view(const _CharT* __s) 23513177Sgibbs : __data(__s), __size(_Traits::length(__s)) {} 23613177Sgibbs 23713177Sgibbs // [string.view.iterators], iterators 2388567Sdg _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 23913177Sgibbs const_iterator begin() const _NOEXCEPT { return cbegin(); } 24023925Sgibbs 24123925Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 24223925Sgibbs const_iterator end() const _NOEXCEPT { return cend(); } 24323925Sgibbs 24423925Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 2454568Sgibbs const_iterator cbegin() const _NOEXCEPT { return __data; } 24613177Sgibbs 24715328Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 24815328Sgibbs const_iterator cend() const _NOEXCEPT { return __data + __size; } 24913177Sgibbs 2506608Sgibbs _LIBCPP_INLINE_VISIBILITY 25123925Sgibbs const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } 25223925Sgibbs 25323925Sgibbs _LIBCPP_INLINE_VISIBILITY 25423925Sgibbs const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } 2556608Sgibbs 25618762Sgibbs _LIBCPP_INLINE_VISIBILITY 25718762Sgibbs const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } 25818762Sgibbs 25918762Sgibbs _LIBCPP_INLINE_VISIBILITY 26018762Sgibbs const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } 26123925Sgibbs 26223925Sgibbs // [string.view.capacity], capacity 2636608Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 2648104Sgibbs size_type size() const _NOEXCEPT { return __size; } 26525005Sgibbs 26625005Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 26725005Sgibbs size_type length() const _NOEXCEPT { return __size; } 26825005Sgibbs 26925005Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 27025005Sgibbs size_type max_size() const _NOEXCEPT { return _VSTD::numeric_limits<size_type>::max(); } 27125005Sgibbs 27213177Sgibbs _LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY 27322451Sgibbs empty() const _NOEXCEPT { return __size == 0; } 27422451Sgibbs 27523925Sgibbs // [string.view.access], element access 27623925Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 27722451Sgibbs const_reference operator[](size_type __pos) const { return __data[__pos]; } 27823925Sgibbs 27923925Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 28023925Sgibbs const_reference at(size_type __pos) const 28122451Sgibbs { 28223925Sgibbs return __pos >= size() 28323925Sgibbs ? throw out_of_range("string_view::at") 28423925Sgibbs : __data[__pos]; 28523925Sgibbs// if (__pos >= size()) 28623925Sgibbs// throw out_of_range("string_view::at"); 28722451Sgibbs// return __data[__pos]; 28822451Sgibbs } 28913177Sgibbs 29019164Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 29119164Sgibbs const_reference front() const 29213177Sgibbs { 29319164Sgibbs return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0]; 29423925Sgibbs } 29523925Sgibbs 29623925Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 29723925Sgibbs const_reference back() const 29819164Sgibbs { 29923925Sgibbs return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1]; 30023925Sgibbs } 30113177Sgibbs 30215843Sgibbs _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 30313177Sgibbs const_pointer data() const _NOEXCEPT { return __data; } 30413177Sgibbs 30513177Sgibbs // [string.view.modifiers], modifiers: 30613177Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 30713177Sgibbs void clear() _NOEXCEPT 30813177Sgibbs { 30913177Sgibbs __data = nullptr; 3104568Sgibbs __size = 0; 31124794Sgibbs } 31224794Sgibbs 3134568Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 31423925Sgibbs void remove_prefix(size_type __n) _NOEXCEPT 31523925Sgibbs { 31623925Sgibbs _LIBCPP_ASSERT(n <= size(), "remove_prefix() can't remove more than size()"); 3174568Sgibbs __data += __n; 31823925Sgibbs __size -= __n; 31923925Sgibbs } 32023925Sgibbs 32123925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 32223925Sgibbs void remove_suffix(size_type __n) _NOEXCEPT 32323925Sgibbs { 3244568Sgibbs _LIBCPP_ASSERT(n <= size(), "remove_suffix() can't remove more than size()"); 32523925Sgibbs __size -= __n; 32623925Sgibbs } 3274568Sgibbs 32823925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 32923925Sgibbs void swap(basic_string_view& __other) _NOEXCEPT 33024794Sgibbs { 33123925Sgibbs const value_type *__p = __data; 33223925Sgibbs __data = __other.__data; 33323925Sgibbs __other.__data = __p; 33423925Sgibbs 33523925Sgibbs size_type __sz = __size; 33623925Sgibbs __size = __other.__size; 33723925Sgibbs __other.__size = __sz; 33823925Sgibbs// _VSTD::swap( __data, __other.__data ); 33923925Sgibbs// _VSTD::swap( __size, __other.__size ); 34023925Sgibbs } 34123925Sgibbs 34223925Sgibbs // [string.view.ops], string operations: 34323925Sgibbs template<class _Allocator> 34423925Sgibbs _LIBCPP_INLINE_VISIBILITY 34523925Sgibbs _LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const 34623925Sgibbs { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); } 34723925Sgibbs 3484568Sgibbs template<class _Allocator = allocator<_CharT> > 34923925Sgibbs _LIBCPP_INLINE_VISIBILITY 35023925Sgibbs basic_string<_CharT, _Traits, _Allocator> 3514568Sgibbs to_string( const _Allocator& __a = _Allocator()) const 35213177Sgibbs { return basic_string<_CharT, _Traits, _Allocator> ( begin(), end(), __a ); } 35313177Sgibbs 35413177Sgibbs size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const 35513177Sgibbs { 3569928Sgibbs if ( __pos > size()) 35723925Sgibbs throw out_of_range("string_view::copy"); 35823925Sgibbs size_type __rlen = _VSTD::min( __n, size() - __pos ); 35923925Sgibbs _VSTD::copy_n(begin() + __pos, __rlen, __s ); 3604568Sgibbs return __rlen; 3619928Sgibbs } 36223925Sgibbs 3639928Sgibbs _LIBCPP_CONSTEXPR 36423925Sgibbs basic_string_view substr(size_type __pos = 0, size_type __n = npos) const 36519164Sgibbs { 36619164Sgibbs// if (__pos > size()) 36719164Sgibbs// throw out_of_range("string_view::substr"); 3685775Sgibbs// size_type __rlen = _VSTD::min( __n, size() - __pos ); 36923925Sgibbs// return basic_string_view(data() + __pos, __rlen); 3704568Sgibbs return __pos > size() 37119164Sgibbs ? throw out_of_range("string_view::substr") 37219164Sgibbs : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos)); 37319164Sgibbs } 37419164Sgibbs 37519164Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT 37619164Sgibbs { 37723925Sgibbs size_type __rlen = _VSTD::min( size(), __sv.size()); 37823925Sgibbs int __retval = _Traits::compare(data(), __sv.data(), __rlen); 37919164Sgibbs if ( __retval == 0 ) // first __rlen chars matched 38023925Sgibbs __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 ); 38119164Sgibbs return __retval; 38223925Sgibbs } 38319164Sgibbs 38423925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 38523925Sgibbs int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const 38619164Sgibbs { 3879928Sgibbs return substr(__pos1, __n1).compare(__sv); 38816260Sgibbs } 38923925Sgibbs 39016260Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 39116260Sgibbs int compare( size_type __pos1, size_type __n1, 39216260Sgibbs basic_string_view _sv, size_type __pos2, size_type __n2) const 39316260Sgibbs { 39416260Sgibbs return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2)); 39516260Sgibbs } 39623925Sgibbs 39723925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 39823925Sgibbs int compare(const _CharT* __s) const 39923925Sgibbs { 40023925Sgibbs return compare(basic_string_view(__s)); 40116260Sgibbs } 40216260Sgibbs 40319164Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 40423925Sgibbs int compare(size_type __pos1, size_type __n1, const _CharT* __s) const 40523925Sgibbs { 4069928Sgibbs return substr(__pos1, __n1).compare(basic_string_view(__s)); 40723925Sgibbs } 4084568Sgibbs 40916260Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 41023925Sgibbs int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const 41116260Sgibbs { 41222451Sgibbs return substr(__pos1, __n1).compare(basic_string_view(__s, __n2)); 41323925Sgibbs } 4147532Sgibbs 41513177Sgibbs // find 41613177Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 41713177Sgibbs size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT 4189928Sgibbs { 41923925Sgibbs _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr"); 4204568Sgibbs return _VSTD::__str_find<value_type, size_type, traits_type, npos> 42123925Sgibbs (data(), size(), __s.data(), __pos, __s.size()); 4224568Sgibbs } 42323925Sgibbs 42423925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 42523925Sgibbs size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT 4264568Sgibbs { 42713177Sgibbs return _VSTD::__str_find<value_type, size_type, traits_type, npos> 42813177Sgibbs (data(), size(), __c, __pos); 42913177Sgibbs } 43013177Sgibbs 43113177Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 43215328Sgibbs size_type find(const _CharT* __s, size_type __pos, size_type __n) const 43313177Sgibbs { 4349928Sgibbs _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): recieved nullptr"); 43523925Sgibbs return _VSTD::__str_find<value_type, size_type, traits_type, npos> 43623925Sgibbs (data(), size(), __s, __pos, __n); 4374568Sgibbs } 43823925Sgibbs 43923925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 44023925Sgibbs size_type find(const _CharT* __s, size_type __pos = 0) const 44122568Sgibbs { 44223925Sgibbs _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): recieved nullptr"); 4439928Sgibbs return _VSTD::__str_find<value_type, size_type, traits_type, npos> 44423925Sgibbs (data(), size(), __s, __pos, traits_type::length(__s)); 4459928Sgibbs } 44613177Sgibbs 44713177Sgibbs // rfind 44819164Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 44913177Sgibbs size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT 45013177Sgibbs { 45119164Sgibbs _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr"); 45219164Sgibbs return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> 45313177Sgibbs (data(), size(), __s.data(), __pos, __s.size()); 45413177Sgibbs } 45523925Sgibbs 4569928Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 45713177Sgibbs size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT 45823925Sgibbs { 45923925Sgibbs return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> 4604568Sgibbs (data(), size(), __c, __pos); 4619928Sgibbs } 46213177Sgibbs 46313177Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 46413177Sgibbs size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const 46513177Sgibbs { 46613177Sgibbs _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): recieved nullptr"); 46723925Sgibbs return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> 46823925Sgibbs (data(), size(), __s, __pos, __n); 46923925Sgibbs } 47023925Sgibbs 47122568Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 47222568Sgibbs size_type rfind(const _CharT* __s, size_type __pos=npos) const 47323925Sgibbs { 47422568Sgibbs _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): recieved nullptr"); 47523925Sgibbs return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> 4764568Sgibbs (data(), size(), __s, __pos, traits_type::length(__s)); 47716260Sgibbs } 47813177Sgibbs 47916260Sgibbs // find_first_of 48016260Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 48123925Sgibbs size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT 48223925Sgibbs { 48323925Sgibbs _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): recieved nullptr"); 48416260Sgibbs return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> 48516260Sgibbs (data(), size(), __s.data(), __pos, __s.size()); 48615328Sgibbs } 48713177Sgibbs 4884568Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 48923925Sgibbs size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT 4904568Sgibbs { return find(__c, __pos); } 49113177Sgibbs 49215328Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 49313177Sgibbs size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const 49423925Sgibbs { 49523925Sgibbs _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): recieved nullptr"); 49623925Sgibbs return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> 49723925Sgibbs (data(), size(), __s, __pos, __n); 4984568Sgibbs } 49923925Sgibbs 5004568Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 50123925Sgibbs size_type find_first_of(const _CharT* __s, size_type __pos=0) const 50223925Sgibbs { 5034568Sgibbs _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): recieved nullptr"); 50413177Sgibbs return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> 50513177Sgibbs (data(), size(), __s, __pos, traits_type::length(__s)); 50613177Sgibbs } 50713177Sgibbs 5084568Sgibbs // find_last_of 50923925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 51019803Sgibbs size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT 51123925Sgibbs { 51223925Sgibbs _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): recieved nullptr"); 5134568Sgibbs return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> 51413177Sgibbs (data(), size(), __s.data(), __pos, __s.size()); 51515328Sgibbs } 51613177Sgibbs 51713177Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 5184568Sgibbs size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT 51923925Sgibbs { return rfind(__c, __pos); } 52023925Sgibbs 52113177Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 52213177Sgibbs size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const 52323925Sgibbs { 52413177Sgibbs _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): recieved nullptr"); 52513177Sgibbs return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> 52623925Sgibbs (data(), size(), __s, __pos, __n); 52723925Sgibbs } 5284568Sgibbs 52913177Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 53013177Sgibbs size_type find_last_of(const _CharT* __s, size_type __pos=npos) const 53113177Sgibbs { 53223925Sgibbs _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): recieved nullptr"); 53323925Sgibbs return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> 53423925Sgibbs (data(), size(), __s, __pos, traits_type::length(__s)); 53513177Sgibbs } 53613177Sgibbs 53713177Sgibbs // find_first_not_of 53813177Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 53913177Sgibbs size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT 54024794Sgibbs { 54124794Sgibbs _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): recieved nullptr"); 54223925Sgibbs return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> 54323925Sgibbs (data(), size(), __s.data(), __pos, __s.size()); 54425005Sgibbs } 54525005Sgibbs 54625005Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 54725005Sgibbs size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT 54813177Sgibbs { 54913177Sgibbs return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> 55013177Sgibbs (data(), size(), __c, __pos); 55113177Sgibbs } 55224914Sgibbs 55324914Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 55424914Sgibbs size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const 55519906Sgibbs { 55623925Sgibbs _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): recieved nullptr"); 55723925Sgibbs return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> 55823925Sgibbs (data(), size(), __s, __pos, __n); 5594568Sgibbs } 56019906Sgibbs 56123925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 56223925Sgibbs size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const 56323925Sgibbs { 5644568Sgibbs _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): recieved nullptr"); 56513177Sgibbs return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> 56613177Sgibbs (data(), size(), __s, __pos, traits_type::length(__s)); 56713177Sgibbs } 5684568Sgibbs 56923925Sgibbs // find_last_not_of 57023925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 5714568Sgibbs size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT 57223925Sgibbs { 57323925Sgibbs _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): recieved nullptr"); 57423925Sgibbs return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> 57523925Sgibbs (data(), size(), __s.data(), __pos, __s.size()); 57623925Sgibbs } 57723925Sgibbs 57823925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 57923925Sgibbs size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT 5804568Sgibbs { 5819954Sgibbs return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> 58213177Sgibbs (data(), size(), __c, __pos); 58319164Sgibbs } 58419164Sgibbs 58519164Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 58613177Sgibbs size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const 58723925Sgibbs { 5889954Sgibbs _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): recieved nullptr"); 58923925Sgibbs return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> 5909954Sgibbs (data(), size(), __s, __pos, __n); 5919954Sgibbs } 59223925Sgibbs 59323925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 5949954Sgibbs size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const 5959954Sgibbs { 5969954Sgibbs _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): recieved nullptr"); 59713177Sgibbs return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> 59819164Sgibbs (data(), size(), __s, __pos, traits_type::length(__s)); 59919164Sgibbs } 60019164Sgibbs 60119164Sgibbs private: 60219164Sgibbs const value_type* __data; 60319164Sgibbs size_type __size; 60419164Sgibbs }; 60519164Sgibbs 60619164Sgibbs 60719164Sgibbs // [string.view.comparison] 60819164Sgibbs // operator == 60919164Sgibbs template<class _CharT, class _Traits> 61019164Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 61119164Sgibbs bool operator==(basic_string_view<_CharT, _Traits> __lhs, 61219164Sgibbs basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 61313177Sgibbs { 61419164Sgibbs if ( __lhs.size() != __rhs.size()) return false; 61513177Sgibbs return __lhs.compare(__rhs) == 0; 61619164Sgibbs } 61713177Sgibbs 61823925Sgibbs template<class _CharT, class _Traits> 61923925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 62019164Sgibbs bool operator==(basic_string_view<_CharT, _Traits> __lhs, 62123925Sgibbs typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 62223925Sgibbs { 6237532Sgibbs if ( __lhs.size() != __rhs.size()) return false; 62423925Sgibbs return __lhs.compare(__rhs) == 0; 62523925Sgibbs } 62623925Sgibbs 62719164Sgibbs template<class _CharT, class _Traits> 62823925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 62923925Sgibbs bool operator==(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 6305326Sgibbs basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 6314568Sgibbs { 63213177Sgibbs if ( __lhs.size() != __rhs.size()) return false; 63323925Sgibbs return __lhs.compare(__rhs) == 0; 63413177Sgibbs } 63513177Sgibbs 63613177Sgibbs 63713177Sgibbs // operator != 63823925Sgibbs template<class _CharT, class _Traits> 63923925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 64023925Sgibbs bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 64123925Sgibbs { 64223925Sgibbs if ( __lhs.size() != __rhs.size()) 6435326Sgibbs return true; 6445326Sgibbs return __lhs.compare(__rhs) != 0; 64519164Sgibbs } 64628169Sgibbs 64728169Sgibbs template<class _CharT, class _Traits> 64828169Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 64928169Sgibbs bool operator!=(basic_string_view<_CharT, _Traits> __lhs, 65028169Sgibbs typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 65128169Sgibbs { 65228169Sgibbs if ( __lhs.size() != __rhs.size()) 65328169Sgibbs return true; 65428169Sgibbs return __lhs.compare(__rhs) != 0; 65523925Sgibbs } 65623925Sgibbs 65723925Sgibbs template<class _CharT, class _Traits> 65823925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 65919164Sgibbs bool operator!=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 66019164Sgibbs basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 66123925Sgibbs { 66223925Sgibbs if ( __lhs.size() != __rhs.size()) 66319164Sgibbs return true; 66423925Sgibbs return __lhs.compare(__rhs) != 0; 66523925Sgibbs } 66625005Sgibbs 66723925Sgibbs 66823925Sgibbs // operator < 66923925Sgibbs template<class _CharT, class _Traits> 67019164Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 67123925Sgibbs bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 67223925Sgibbs { 67319164Sgibbs return __lhs.compare(__rhs) < 0; 67423925Sgibbs } 67523925Sgibbs 67623925Sgibbs template<class _CharT, class _Traits> 67723925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 67823925Sgibbs bool operator<(basic_string_view<_CharT, _Traits> __lhs, 67923925Sgibbs typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 68023925Sgibbs { 68123925Sgibbs return __lhs.compare(__rhs) < 0; 68219921Sgibbs } 68323925Sgibbs 68423925Sgibbs template<class _CharT, class _Traits> 6854568Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 68613177Sgibbs bool operator<(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 68718762Sgibbs basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 68818762Sgibbs { 68918762Sgibbs return __lhs.compare(__rhs) < 0; 69018762Sgibbs } 69113177Sgibbs 6929954Sgibbs 69323925Sgibbs // operator > 69423925Sgibbs template<class _CharT, class _Traits> 69518762Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 69623925Sgibbs bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 69723925Sgibbs { 69823925Sgibbs return __lhs.compare(__rhs) > 0; 69923925Sgibbs } 70019164Sgibbs 70123925Sgibbs template<class _CharT, class _Traits> 70218762Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 70323925Sgibbs bool operator>(basic_string_view<_CharT, _Traits> __lhs, 70423925Sgibbs typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 70523925Sgibbs { 70618762Sgibbs return __lhs.compare(__rhs) > 0; 70723925Sgibbs } 70823925Sgibbs 7095562Sgibbs template<class _CharT, class _Traits> 71013177Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 71113177Sgibbs bool operator>(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 71213177Sgibbs basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 71313177Sgibbs { 7149954Sgibbs return __lhs.compare(__rhs) > 0; 71523925Sgibbs } 71623925Sgibbs 71723925Sgibbs 71823925Sgibbs // operator <= 71923925Sgibbs template<class _CharT, class _Traits> 72019164Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 72115328Sgibbs bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 72219164Sgibbs { 72319164Sgibbs return __lhs.compare(__rhs) <= 0; 72419164Sgibbs } 72519164Sgibbs 72619164Sgibbs template<class _CharT, class _Traits> 72715328Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 72819164Sgibbs bool operator<=(basic_string_view<_CharT, _Traits> __lhs, 72923925Sgibbs typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 73023925Sgibbs { 7314568Sgibbs return __lhs.compare(__rhs) <= 0; 73219164Sgibbs } 73323925Sgibbs 73423925Sgibbs template<class _CharT, class _Traits> 73519164Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 73619164Sgibbs bool operator<=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 73723925Sgibbs basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 73823925Sgibbs { 73919164Sgibbs return __lhs.compare(__rhs) <= 0; 74013177Sgibbs } 74119164Sgibbs 74213177Sgibbs 74323925Sgibbs // operator >= 74419164Sgibbs template<class _CharT, class _Traits> 74523925Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 7464568Sgibbs bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 74713177Sgibbs { 74813177Sgibbs return __lhs.compare(__rhs) >= 0; 74913177Sgibbs } 75013177Sgibbs 75113177Sgibbs 75213177Sgibbs template<class _CharT, class _Traits> 7539954Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 75423925Sgibbs bool operator>=(basic_string_view<_CharT, _Traits> __lhs, 75523925Sgibbs typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT 75613177Sgibbs { 75723925Sgibbs return __lhs.compare(__rhs) >= 0; 75813177Sgibbs } 75923925Sgibbs 7604568Sgibbs template<class _CharT, class _Traits> 76113177Sgibbs _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 76213177Sgibbs bool operator>=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 76313177Sgibbs basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT 76413177Sgibbs { 76513177Sgibbs return __lhs.compare(__rhs) >= 0; 7669954Sgibbs } 76723925Sgibbs 76823925Sgibbs 76923925Sgibbs // [string.view.io] 77023925Sgibbs template<class _CharT, class _Traits> 77123925Sgibbs basic_ostream<_CharT, _Traits>& 77224608Sgibbs operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv) 77323925Sgibbs { 77424608Sgibbs return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size()); 77524608Sgibbs } 77624608Sgibbs 77724608Sgibbs typedef basic_string_view<char> string_view; 77824608Sgibbs typedef basic_string_view<char16_t> u16string_view; 77924608Sgibbs typedef basic_string_view<char32_t> u32string_view; 78024608Sgibbs typedef basic_string_view<wchar_t> wstring_view; 78113177Sgibbs 78213177Sgibbs_LIBCPP_END_NAMESPACE_LFTS 78323168Sgibbs_LIBCPP_BEGIN_NAMESPACE_STD 78415328Sgibbs 78515328Sgibbs// [string.view.hash] 78615328Sgibbs// Shamelessly stolen from <string> 78715328Sgibbstemplate<class _CharT, class _Traits> 78813177Sgibbsstruct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::basic_string_view<_CharT, _Traits> > 78924608Sgibbs : public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t> 79023925Sgibbs{ 79113177Sgibbs size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT; 79223925Sgibbs}; 79324794Sgibbs 79423925Sgibbstemplate<class _CharT, class _Traits> 79523925Sgibbssize_t 79623925Sgibbshash<std::experimental::basic_string_view<_CharT, _Traits> >::operator()( 7976608Sgibbs const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT 79823925Sgibbs{ 79923925Sgibbs return __do_string_hash(__val.data(), __val.data() + __val.size()); 80013177Sgibbs} 80113177Sgibbs 80213177Sgibbs#if _LIBCPP_STD_VER > 11 80313177Sgibbstemplate <class _CharT, class _Traits> 80413177Sgibbs__quoted_output_proxy<_CharT, const _CharT *, _Traits> 80523925Sgibbsquoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv, 80623925Sgibbs _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) 80723925Sgibbs{ 80813177Sgibbs return __quoted_output_proxy<_CharT, const _CharT *, _Traits> 80923925Sgibbs ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape ); 81024608Sgibbs} 81124608Sgibbs#endif 81224608Sgibbs 81324608Sgibbs_LIBCPP_END_NAMESPACE_STD 81424608Sgibbs 81524608Sgibbs#endif // _LIBCPP_LFTS_STRING_VIEW 81624608Sgibbs