11#ifndef _LIBCPP_LFTS_STRING_VIEW
12#define _LIBCPP_LFTS_STRING_VIEW
14#ifndef RWrap_libcpp_string_view_h
15#error "Do not use libcpp_string_view.h directly. #include \"RWrap_libcpp_string_view.h\" instead."
193#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
194#pragma GCC system_header
199 template<
class _CharT,
class _Traits = _VSTD::
char_traits<_CharT> >
227 template<
class _Allocator>
230 : __data (__str.data()), __size(__str.size()) {}
234 : __data(__s), __size(__len)
241 : __data(__s), __size(_Traits::length(__s)) {}
288 return __pos >= size()
289 ? (
throw out_of_range(
"string_view::at"), __data[0])
296 return _LIBCPP_ASSERT(!empty(),
"string_view::front(): string is empty"), __data[0];
302 return _LIBCPP_ASSERT(!empty(),
"string_view::back(): string is empty"), __data[__size-1];
319 _LIBCPP_ASSERT(__n <= size(),
"remove_prefix() can't remove more than size()");
327 _LIBCPP_ASSERT(__n <= size(),
"remove_suffix() can't remove more than size()");
335 __data = __other.__data;
336 __other.__data = __p;
339 __size = __other.__size;
340 __other.__size = __sz;
346 template<
class _Allocator>
349 {
return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
354 throw out_of_range(
"string_view::copy");
355 size_type __rlen = (_VSTD::min)( __n, size() - __pos );
356 _VSTD::copy_n(begin() + __pos, __rlen, __s );
367 return __pos > size()
368 ?
throw out_of_range(
"string_view::substr")
374 size_type __rlen = (_VSTD::min)( size(), __sv.size());
375 int __retval = _Traits::compare(data(), __sv.data(), __rlen);
377 __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
384 return substr(__pos1, __n1).compare(__sv);
391 return substr(__pos1, __n1).compare(_sv.
substr(__pos2, __n2));
417 return _VSTD::__str_find<value_type, size_type, traits_type, npos>
418 (data(), size(), __s.
data(), __pos, __s.
size());
424 return _VSTD::__str_find<value_type, size_type, traits_type, npos>
425 (data(), size(), __c, __pos);
431 _LIBCPP_ASSERT(__n == 0 || __s !=
nullptr,
"string_view::find(): recieved nullptr");
432 return _VSTD::__str_find<value_type, size_type, traits_type, npos>
433 (data(), size(), __s, __pos, __n);
439 _LIBCPP_ASSERT(__s !=
nullptr,
"string_view::find(): recieved nullptr");
440 return _VSTD::__str_find<value_type, size_type, traits_type, npos>
441 (data(), size(), __s, __pos, traits_type::length(__s));
448 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() !=
nullptr,
"string_view::find(): recieved nullptr");
449 return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
450 (data(), size(), __s.data(), __pos, __s.size());
456 return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
457 (data(), size(), __c, __pos);
463 _LIBCPP_ASSERT(__n == 0 || __s !=
nullptr,
"string_view::rfind(): recieved nullptr");
464 return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
465 (data(), size(), __s, __pos, __n);
471 _LIBCPP_ASSERT(__s !=
nullptr,
"string_view::rfind(): recieved nullptr");
472 return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
473 (data(), size(), __s, __pos, traits_type::length(__s));
480 _LIBCPP_ASSERT(__s.
size() == 0 || __s.
data() !=
nullptr,
"string_view::find_first_of(): recieved nullptr");
481 return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
482 (data(), size(), __s.
data(), __pos, __s.
size());
487 {
return find(__c, __pos); }
492 _LIBCPP_ASSERT(__n == 0 || __s !=
nullptr,
"string_view::find_first_of(): recieved nullptr");
493 return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
494 (data(), size(), __s, __pos, __n);
500 _LIBCPP_ASSERT(__s !=
nullptr,
"string_view::find_first_of(): recieved nullptr");
501 return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
502 (data(), size(), __s, __pos, traits_type::length(__s));
509 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() !=
nullptr,
"string_view::find_last_of(): recieved nullptr");
510 return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
511 (data(), size(), __s.data(), __pos, __s.size());
516 {
return rfind(__c, __pos); }
521 _LIBCPP_ASSERT(__n == 0 || __s !=
nullptr,
"string_view::find_last_of(): recieved nullptr");
522 return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
523 (data(), size(), __s, __pos, __n);
529 _LIBCPP_ASSERT(__s !=
nullptr,
"string_view::find_last_of(): recieved nullptr");
530 return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
531 (data(), size(), __s, __pos, traits_type::length(__s));
538 _LIBCPP_ASSERT(__s.
size() == 0 || __s.
data() !=
nullptr,
"string_view::find_first_not_of(): recieved nullptr");
539 return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
540 (data(), size(), __s.
data(), __pos, __s.
size());
546 return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
547 (data(), size(), __c, __pos);
553 _LIBCPP_ASSERT(__n == 0 || __s !=
nullptr,
"string_view::find_first_not_of(): recieved nullptr");
554 return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
555 (data(), size(), __s, __pos, __n);
561 _LIBCPP_ASSERT(__s !=
nullptr,
"string_view::find_first_not_of(): recieved nullptr");
562 return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
563 (data(), size(), __s, __pos, traits_type::length(__s));
570 _LIBCPP_ASSERT(__s.size() == 0 || __s.data() !=
nullptr,
"string_view::find_last_not_of(): recieved nullptr");
571 return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
572 (data(), size(), __s.data(), __pos, __s.size());
578 return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
579 (data(), size(), __c, __pos);
585 _LIBCPP_ASSERT(__n == 0 || __s !=
nullptr,
"string_view::find_last_not_of(): recieved nullptr");
586 return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
587 (data(), size(), __s, __pos, __n);
593 _LIBCPP_ASSERT(__s !=
nullptr,
"string_view::find_last_not_of(): recieved nullptr");
594 return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
595 (data(), size(), __s, __pos, traits_type::length(__s));
606 template<
class _CharT,
class _Traits>
611 if ( __lhs.size() != __rhs.size())
return false;
612 return __lhs.compare(__rhs) == 0;
615 template<
class _CharT,
class _Traits>
620 if ( __lhs.size() != __rhs.size())
return false;
621 return __lhs.compare(__rhs) == 0;
624 template<
class _CharT,
class _Traits>
629 if ( __lhs.size() != __rhs.size())
return false;
630 return __lhs.compare(__rhs) == 0;
634 template<
class _CharT,
class _Traits>
640 if ( __lhs.size() != __rhsv.size())
return false;
641 return __lhs.compare(__rhsv) == 0;
647 template<
class _CharT,
class _Traits>
651 if ( __lhs.size() != __rhs.size())
653 return __lhs.compare(__rhs) != 0;
656 template<
class _CharT,
class _Traits>
661 if ( __lhs.size() != __rhs.size())
663 return __lhs.compare(__rhs) != 0;
666 template<
class _CharT,
class _Traits>
671 if ( __lhs.size() != __rhs.size())
673 return __lhs.compare(__rhs) != 0;
678 template<
class _CharT,
class _Traits>
682 return __lhs.compare(__rhs) < 0;
685 template<
class _CharT,
class _Traits>
690 return __lhs.compare(__rhs) < 0;
693 template<
class _CharT,
class _Traits>
698 return __lhs.compare(__rhs) < 0;
703 template<
class _CharT,
class _Traits>
707 return __lhs.compare(__rhs) > 0;
710 template<
class _CharT,
class _Traits>
715 return __lhs.compare(__rhs) > 0;
718 template<
class _CharT,
class _Traits>
723 return __lhs.compare(__rhs) > 0;
728 template<
class _CharT,
class _Traits>
732 return __lhs.compare(__rhs) <= 0;
735 template<
class _CharT,
class _Traits>
740 return __lhs.compare(__rhs) <= 0;
743 template<
class _CharT,
class _Traits>
748 return __lhs.compare(__rhs) <= 0;
753 template<
class _CharT,
class _Traits>
757 return __lhs.compare(__rhs) >= 0;
761 template<
class _CharT,
class _Traits>
766 return __lhs.compare(__rhs) >= 0;
769 template<
class _CharT,
class _Traits>
774 return __lhs.compare(__rhs) >= 0;
779 template<
class _CharT,
class _Traits>
780 basic_ostream<_CharT, _Traits>&
783 return _VSTD::R__put_character_sequence(__os, __sv.
data(), __sv.
size());
796template<
class _CharT,
class _Traits>
798 :
public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t>
800 size_t operator()(
const std::experimental::basic_string_view<_CharT, _Traits>& __val)
const _NOEXCEPT;
803template<
class _CharT,
class _Traits>
805hash<std::experimental::basic_string_view<_CharT, _Traits> >::operator()(
806 const std::experimental::basic_string_view<_CharT, _Traits>& __val)
const _NOEXCEPT
808 return __do_string_hash(__val.data(), __val.data() + __val.size());
811#if _LIBCPP_STD_VER > 11
812template <
class _CharT,
class _Traits>
813__quoted_output_proxy<_CharT, const _CharT *, _Traits>
814quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv,
815 _CharT __delim = _CharT(
'"'), _CharT __escape=_CharT(
'\\'))
817 return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
818 ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
#define _LIBCPP_END_NAMESPACE_STD
#define _LIBCPP_INLINE_VISIBILITY
#define _ROOT_LIBCPP_END_NAMESPACE_LFTS
#define _LIBCPP_CONSTEXPR_AFTER_CXX11
#define _LIBCPP_TYPE_VIS_ONLY
#define _LIBCPP_CONSTEXPR
#define _ROOT_LIBCPP_BEGIN_NAMESPACE_LFTS
#define _LIBCPP_ASSERT(X, Y)
#define _LIBCPP_BEGIN_NAMESPACE_STD
TRObject operator()(const T1 &t1) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT *__s, size_type __pos=0) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
const _CharT & const_reference
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const _CharT *__s)
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const basic_string_view &) _NOEXCEPT=default
ptrdiff_t difference_type
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT
_LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY empty() const _NOEXCEPT
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const _CharT *__s, size_type __len)
_LIBCPP_INLINE_VISIBILITY basic_string_view(const basic_string< _CharT, _Traits, _Allocator > &__str) _NOEXCEPT
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const _NOEXCEPT
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const _CharT *__s, size_type __n2) const
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void swap(basic_string_view &__other) _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const _NOEXCEPT
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view() _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(_CharT __c, size_type __pos=0) const _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const _NOEXCEPT
const_pointer const_iterator
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT *__s, size_type __pos=0) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
const_reverse_iterator reverse_iterator
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT *__s, size_type __pos=npos) const
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_pointer data() const _NOEXCEPT
_VSTD::reverse_iterator< const_iterator > const_reverse_iterator
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT *__s, size_type __pos=npos) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT *__s, size_type __pos, size_type __n) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(_CharT __c, size_type __pos=npos) const _NOEXCEPT
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const _CharT *__s) const
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT *__s, size_type __pos, size_type __n) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT *__s, size_type __pos, size_type __n) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT *__s, size_type __pos, size_type __n) const
_LIBCPP_CONSTEXPR basic_string_view substr(size_type __pos=0, size_type __n=npos) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT *__s, size_type __pos, size_type __n) const
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference back() const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY basic_string_view & operator=(const basic_string_view &) _NOEXCEPT=default
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_prefix(size_type __n) _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(const _CharT *__s) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
const _CharT * const_pointer
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __pos) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, basic_string_view _sv, size_type __pos2, size_type __n2) const
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference front() const
const value_type * __data
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT *__s, size_type __pos, size_type __n) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_suffix(size_type __n) _NOEXCEPT
basic_string_view< char32_t > u32string_view
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>=(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
basic_string_view< char > string_view
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator!=(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
basic_ostream< _CharT, _Traits > & operator<<(basic_ostream< _CharT, _Traits > &__os, basic_string_view< _CharT, _Traits > __sv)
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator==(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
basic_string_view< char16_t > u16string_view
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
basic_string_view< wchar_t > wstring_view
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<=(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT