Logo ROOT  
Reference Guide
libcpp_string_view.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //===------------------------ string_view ---------------------------------===//
3 //
4 // The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 
11 #ifndef _LIBCPP_LFTS_STRING_VIEW
12 #define _LIBCPP_LFTS_STRING_VIEW
13 
14 #ifndef RWrap_libcpp_string_view_h
15 #error "Do not use libcpp_string_view.h directly. #include \"RWrap_libcpp_string_view.h\" instead."
16 #endif // RWrap_libcpp_string_view_h
17 
18 /*
19 string_view synopsis
20 
21 namespace std {
22  namespace experimental {
23  inline namespace library_fundamentals_v1 {
24 
25  // 7.2, Class template basic_string_view
26  template<class charT, class traits = char_traits<charT>>
27  class basic_string_view;
28 
29  // 7.9, basic_string_view non-member comparison functions
30  template<class charT, class traits>
31  constexpr bool operator==(basic_string_view<charT, traits> x,
32  basic_string_view<charT, traits> y) noexcept;
33  template<class charT, class traits>
34  constexpr bool operator!=(basic_string_view<charT, traits> x,
35  basic_string_view<charT, traits> y) noexcept;
36  template<class charT, class traits>
37  constexpr bool operator< (basic_string_view<charT, traits> x,
38  basic_string_view<charT, traits> y) noexcept;
39  template<class charT, class traits>
40  constexpr bool operator> (basic_string_view<charT, traits> x,
41  basic_string_view<charT, traits> y) noexcept;
42  template<class charT, class traits>
43  constexpr bool operator<=(basic_string_view<charT, traits> x,
44  basic_string_view<charT, traits> y) noexcept;
45  template<class charT, class traits>
46  constexpr bool operator>=(basic_string_view<charT, traits> x,
47  basic_string_view<charT, traits> y) noexcept;
48  // see below, sufficient additional overloads of comparison functions
49 
50  // 7.10, Inserters and extractors
51  template<class charT, class traits>
52  basic_ostream<charT, traits>&
53  operator<<(basic_ostream<charT, traits>& os,
54  basic_string_view<charT, traits> str);
55 
56  // basic_string_view typedef names
57  typedef basic_string_view<char> string_view;
58  typedef basic_string_view<char16_t> u16string_view;
59  typedef basic_string_view<char32_t> u32string_view;
60  typedef basic_string_view<wchar_t> wstring_view;
61 
62  template<class charT, class traits = char_traits<charT>>
63  class basic_string_view {
64  public:
65  // types
66  typedef traits traits_type;
67  typedef charT value_type;
68  typedef charT* pointer;
69  typedef const charT* const_pointer;
70  typedef charT& reference;
71  typedef const charT& const_reference;
72  typedef implementation-defined const_iterator;
73  typedef const_iterator iterator;
74  typedef reverse_iterator<const_iterator> const_reverse_iterator;
75  typedef const_reverse_iterator reverse_iterator;
76  typedef size_t size_type;
77  typedef ptrdiff_t difference_type;
78  static constexpr size_type npos = size_type(-1);
79 
80  // 7.3, basic_string_view constructors and assignment operators
81  constexpr basic_string_view() noexcept;
82  constexpr basic_string_view(const basic_string_view&) noexcept = default;
83  basic_string_view& operator=(const basic_string_view&) noexcept = default;
84  template<class Allocator>
85  basic_string_view(const basic_string<charT, traits, Allocator>& str) noexcept;
86  constexpr basic_string_view(const charT* str);
87  constexpr basic_string_view(const charT* str, size_type len);
88 
89  // 7.4, basic_string_view iterator support
90  constexpr const_iterator begin() const noexcept;
91  constexpr const_iterator end() const noexcept;
92  constexpr const_iterator cbegin() const noexcept;
93  constexpr const_iterator cend() const noexcept;
94  const_reverse_iterator rbegin() const noexcept;
95  const_reverse_iterator rend() const noexcept;
96  const_reverse_iterator crbegin() const noexcept;
97  const_reverse_iterator crend() const noexcept;
98 
99  // 7.5, basic_string_view capacity
100  constexpr size_type size() const noexcept;
101  constexpr size_type length() const noexcept;
102  constexpr size_type max_size() const noexcept;
103  constexpr bool empty() const noexcept;
104 
105  // 7.6, basic_string_view element access
106  constexpr const_reference operator[](size_type pos) const;
107  constexpr const_reference at(size_type pos) const;
108  constexpr const_reference front() const;
109  constexpr const_reference back() const;
110  constexpr const_pointer data() const noexcept;
111 
112  // 7.7, basic_string_view modifiers
113  constexpr void clear() noexcept;
114  constexpr void remove_prefix(size_type n);
115  constexpr void remove_suffix(size_type n);
116  constexpr void swap(basic_string_view& s) noexcept;
117 
118  // 7.8, basic_string_view string operations
119  // This one was replaced by a string ctor on the way to std::string_view. Keep it
120  // because we need to do the conversion string(string_view) somehow!
121  template<class Allocator>
122  explicit operator basic_string<charT, traits, Allocator>() const;
123  Axel removed to_string which was kicked out on the way to std::string_view.
124 
125  size_type copy(charT* s, size_type n, size_type pos = 0) const;
126 
127  constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
128  constexpr int compare(basic_string_view s) const noexcept;
129  constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
130  constexpr int compare(size_type pos1, size_type n1,
131  basic_string_view s, size_type pos2, size_type n2) const;
132  constexpr int compare(const charT* s) const;
133  constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
134  constexpr int compare(size_type pos1, size_type n1,
135  const charT* s, size_type n2) const;
136  constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
137  constexpr size_type find(charT c, size_type pos = 0) const noexcept;
138  constexpr size_type find(const charT* s, size_type pos, size_type n) const;
139  constexpr size_type find(const charT* s, size_type pos = 0) const;
140  constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
141  constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
142  constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
143  constexpr size_type rfind(const charT* s, size_type pos = npos) const;
144  constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
145  constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
146  constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
147  constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
148  constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
149  constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
150  constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
151  constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
152  constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
153  constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
154  constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
155  constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
156  constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
157  constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
158  constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
159  constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
160 
161  private:
162  const_pointer data_; // exposition only
163  size_type size_; // exposition only
164  };
165 
166  } // namespace fundamentals_v1
167  } // namespace experimental
168 
169  // 7.11, Hash support
170  template <class T> struct hash;
171  template <> struct hash<experimental::string_view>;
172  template <> struct hash<experimental::u16string_view>;
173  template <> struct hash<experimental::u32string_view>;
174  template <> struct hash<experimental::wstring_view>;
175 
176 } // namespace std
177 
178 
179 */
180 
181 //#include <experimental/__config>
182 
183 #include <string>
184 #include <algorithm>
185 #include <iterator>
186 #include <ostream>
187 #include <iomanip>
188 #include <stdexcept>
189 #include <limits>
190 
191 //#include <__debug>
192 
193 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) && !defined(_MSC_VER)
194 #pragma GCC system_header
195 #endif
196 
198 
199  template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
201  public:
202  // types
203  typedef _Traits traits_type;
204  typedef _CharT value_type;
205  typedef const _CharT* pointer;
206  typedef const _CharT* const_pointer;
207  typedef const _CharT& reference;
208  typedef const _CharT& const_reference;
209  typedef const_pointer const_iterator; // See [string.view.iterators]
211  typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
213  typedef size_t size_type;
214  typedef ptrdiff_t difference_type;
215  static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
216 
217  // [string.view.cons], construct/copy
219  basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
220 
223 
226 
227  template<class _Allocator>
229  basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& __str) _NOEXCEPT
230  : __data (__str.data()), __size(__str.size()) {}
231 
233  basic_string_view(const _CharT* __s, size_type __len)
234  : __data(__s), __size(__len)
235  {
236 // _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): recieved nullptr");
237  }
238 
240  basic_string_view(const _CharT* __s)
241  : __data(__s), __size(_Traits::length(__s)) {}
242 
243  // [string.view.iterators], iterators
245  const_iterator begin() const _NOEXCEPT { return cbegin(); }
246 
248  const_iterator end() const _NOEXCEPT { return cend(); }
249 
251  const_iterator cbegin() const _NOEXCEPT { return __data; }
252 
254  const_iterator cend() const _NOEXCEPT { return __data + __size; }
255 
258 
261 
264 
267 
268  // [string.view.capacity], capacity
270  size_type size() const _NOEXCEPT { return __size; }
271 
273  size_type length() const _NOEXCEPT { return __size; }
274 
276  size_type max_size() const _NOEXCEPT { return (_VSTD::numeric_limits<size_type>::max)(); }
277 
279  empty() const _NOEXCEPT { return __size == 0; }
280 
281  // [string.view.access], element access
283  const_reference operator[](size_type __pos) const { return __data[__pos]; }
284 
287  {
288  return __pos >= size()
289  ? (throw out_of_range("string_view::at"), __data[0])
290  : __data[__pos];
291  }
292 
295  {
296  return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
297  }
298 
301  {
302  return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
303  }
304 
306  const_pointer data() const _NOEXCEPT { return __data; }
307 
308  // [string.view.modifiers], modifiers:
311  {
312  __data = nullptr;
313  __size = 0;
314  }
315 
318  {
319  _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
320  __data += __n;
321  __size -= __n;
322  }
323 
326  {
327  _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
328  __size -= __n;
329  }
330 
333  {
334  const value_type *__p = __data;
335  __data = __other.__data;
336  __other.__data = __p;
337 
338  size_type __sz = __size;
339  __size = __other.__size;
340  __other.__size = __sz;
341 // _VSTD::swap( __data, __other.__data );
342 // _VSTD::swap( __size, __other.__size );
343  }
344 
345  // [string.view.ops], string operations:
346  template<class _Allocator>
348  _LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const
349  { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
350 
351  size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
352  {
353  if ( __pos > size())
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 );
357  return __rlen;
358  }
359 
361  basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
362  {
363 // if (__pos > size())
364 // throw out_of_range("string_view::substr");
365 // size_type __rlen = _VSTD::min( __n, size() - __pos );
366 // return basic_string_view(data() + __pos, __rlen);
367  return __pos > size()
368  ? throw out_of_range("string_view::substr")
369  : basic_string_view(data() + __pos, (_VSTD::min)(__n, size() - __pos));
370  }
371 
373  {
374  size_type __rlen = (_VSTD::min)( size(), __sv.size());
375  int __retval = _Traits::compare(data(), __sv.data(), __rlen);
376  if ( __retval == 0 ) // first __rlen chars matched
377  __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
378  return __retval;
379  }
380 
382  int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
383  {
384  return substr(__pos1, __n1).compare(__sv);
385  }
386 
388  int compare( size_type __pos1, size_type __n1,
389  basic_string_view _sv, size_type __pos2, size_type __n2) const
390  {
391  return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2));
392  }
393 
395  int compare(const _CharT* __s) const
396  {
397  return compare(basic_string_view(__s));
398  }
399 
401  int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
402  {
403  return substr(__pos1, __n1).compare(basic_string_view(__s));
404  }
405 
407  int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
408  {
409  return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
410  }
411 
412  // find
415  {
416  _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr");
417  return _VSTD::__str_find<value_type, size_type, traits_type, npos>
418  (data(), size(), __s.data(), __pos, __s.size());
419  }
420 
422  size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
423  {
424  return _VSTD::__str_find<value_type, size_type, traits_type, npos>
425  (data(), size(), __c, __pos);
426  }
427 
429  size_type find(const _CharT* __s, size_type __pos, size_type __n) const
430  {
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);
434  }
435 
437  size_type find(const _CharT* __s, size_type __pos = 0) const
438  {
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));
442  }
443 
444  // rfind
447  {
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());
451  }
452 
454  size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
455  {
456  return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
457  (data(), size(), __c, __pos);
458  }
459 
461  size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const
462  {
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);
466  }
467 
469  size_type rfind(const _CharT* __s, size_type __pos=npos) const
470  {
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));
474  }
475 
476  // find_first_of
479  {
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());
483  }
484 
486  size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
487  { return find(__c, __pos); }
488 
490  size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
491  {
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);
495  }
496 
498  size_type find_first_of(const _CharT* __s, size_type __pos=0) const
499  {
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));
503  }
504 
505  // find_last_of
508  {
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());
512  }
513 
515  size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
516  { return rfind(__c, __pos); }
517 
519  size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
520  {
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);
524  }
525 
527  size_type find_last_of(const _CharT* __s, size_type __pos=npos) const
528  {
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));
532  }
533 
534  // find_first_not_of
537  {
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());
541  }
542 
544  size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
545  {
546  return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
547  (data(), size(), __c, __pos);
548  }
549 
551  size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
552  {
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);
556  }
557 
559  size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const
560  {
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));
564  }
565 
566  // find_last_not_of
569  {
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());
573  }
574 
576  size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
577  {
578  return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
579  (data(), size(), __c, __pos);
580  }
581 
583  size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
584  {
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);
588  }
589 
591  size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const
592  {
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));
596  }
597 
598  private:
601  };
602 
603 
604  // [string.view.comparison]
605  // operator ==
606  template<class _CharT, class _Traits>
610  {
611  if ( __lhs.size() != __rhs.size()) return false;
612  return __lhs.compare(__rhs) == 0;
613  }
614 
615  template<class _CharT, class _Traits>
618  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
619  {
620  if ( __lhs.size() != __rhs.size()) return false;
621  return __lhs.compare(__rhs) == 0;
622  }
623 
624  template<class _CharT, class _Traits>
626  bool operator==(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
628  {
629  if ( __lhs.size() != __rhs.size()) return false;
630  return __lhs.compare(__rhs) == 0;
631  }
632 
633 #ifdef _WIN32
634  template<class _CharT, class _Traits>
637  const _CharT* __rhs) _NOEXCEPT
638  {
640  if ( __lhs.size() != __rhsv.size()) return false;
641  return __lhs.compare(__rhsv) == 0;
642  }
643 #endif
644 
645 
646  // operator !=
647  template<class _CharT, class _Traits>
650  {
651  if ( __lhs.size() != __rhs.size())
652  return true;
653  return __lhs.compare(__rhs) != 0;
654  }
655 
656  template<class _CharT, class _Traits>
659  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
660  {
661  if ( __lhs.size() != __rhs.size())
662  return true;
663  return __lhs.compare(__rhs) != 0;
664  }
665 
666  template<class _CharT, class _Traits>
668  bool operator!=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
670  {
671  if ( __lhs.size() != __rhs.size())
672  return true;
673  return __lhs.compare(__rhs) != 0;
674  }
675 
676 
677  // operator <
678  template<class _CharT, class _Traits>
681  {
682  return __lhs.compare(__rhs) < 0;
683  }
684 
685  template<class _CharT, class _Traits>
688  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
689  {
690  return __lhs.compare(__rhs) < 0;
691  }
692 
693  template<class _CharT, class _Traits>
695  bool operator<(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
697  {
698  return __lhs.compare(__rhs) < 0;
699  }
700 
701 
702  // operator >
703  template<class _CharT, class _Traits>
706  {
707  return __lhs.compare(__rhs) > 0;
708  }
709 
710  template<class _CharT, class _Traits>
713  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
714  {
715  return __lhs.compare(__rhs) > 0;
716  }
717 
718  template<class _CharT, class _Traits>
720  bool operator>(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
722  {
723  return __lhs.compare(__rhs) > 0;
724  }
725 
726 
727  // operator <=
728  template<class _CharT, class _Traits>
731  {
732  return __lhs.compare(__rhs) <= 0;
733  }
734 
735  template<class _CharT, class _Traits>
738  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
739  {
740  return __lhs.compare(__rhs) <= 0;
741  }
742 
743  template<class _CharT, class _Traits>
745  bool operator<=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
747  {
748  return __lhs.compare(__rhs) <= 0;
749  }
750 
751 
752  // operator >=
753  template<class _CharT, class _Traits>
756  {
757  return __lhs.compare(__rhs) >= 0;
758  }
759 
760 
761  template<class _CharT, class _Traits>
764  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
765  {
766  return __lhs.compare(__rhs) >= 0;
767  }
768 
769  template<class _CharT, class _Traits>
771  bool operator>=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
773  {
774  return __lhs.compare(__rhs) >= 0;
775  }
776 
777 
778  // [string.view.io]
779  template<class _CharT, class _Traits>
780  basic_ostream<_CharT, _Traits>&
781  operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv)
782  {
783  return _VSTD::R__put_character_sequence(__os, __sv.data(), __sv.size());
784  }
785 
790 
793 
794 // [string.view.hash]
795 // Shamelessly stolen from <string>
796 template<class _CharT, class _Traits>
797 struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::basic_string_view<_CharT, _Traits> >
798  : public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t>
799 {
800  size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT;
801 };
802 
803 template<class _CharT, class _Traits>
804 size_t
805 hash<std::experimental::basic_string_view<_CharT, _Traits> >::operator()(
806  const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT
807 {
808  return __do_string_hash(__val.data(), __val.data() + __val.size());
809 }
810 
811 #if _LIBCPP_STD_VER > 11
812 template <class _CharT, class _Traits>
813 __quoted_output_proxy<_CharT, const _CharT *, _Traits>
814 quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv,
815  _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
816 {
817  return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
818  ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
819 }
820 #endif
821 
823 
824 #endif // _LIBCPP_LFTS_STRING_VIEW
_LIBCPP_INLINE_VISIBILITY
#define _LIBCPP_INLINE_VISIBILITY
Definition: RWrap_libcpp_string_view.h:82
basic_string_view::compare
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const _CharT *__s) const
Definition: libcpp_string_view.h:401
basic_string_view::reference
const _CharT & reference
Definition: libcpp_string_view.h:207
basic_string_view::basic_string_view
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const _CharT *__s, size_type __len)
Definition: libcpp_string_view.h:233
basic_string_view::find
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
Definition: libcpp_string_view.h:414
basic_string_view::__data
const value_type * __data
Definition: libcpp_string_view.h:599
basic_string_view::rfind
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(_CharT __c, size_type __pos=npos) const _NOEXCEPT
Definition: libcpp_string_view.h:454
_LIBCPP_EXPLICIT
#define _LIBCPP_EXPLICIT
Definition: RWrap_libcpp_string_view.h:87
_LIBCPP_END_NAMESPACE_STD
#define _LIBCPP_END_NAMESPACE_STD
Definition: RWrap_libcpp_string_view.h:67
operator>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
Definition: libcpp_string_view.h:705
basic_string_view::basic_string_view
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const _CharT *__s)
Definition: libcpp_string_view.h:240
basic_string_view
Definition: libcpp_string_view.h:200
basic_string_view::find_first_not_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT *__s, size_type __pos, size_type __n) const
Definition: libcpp_string_view.h:551
basic_string_view::end
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT
Definition: libcpp_string_view.h:248
basic_string_view::rfind
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT *__s, size_type __pos, size_type __n) const
Definition: libcpp_string_view.h:461
string_view
basic_string_view< char > string_view
Definition: libcpp_string_view.h:786
basic_string_view::compare
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
Definition: libcpp_string_view.h:372
basic_string_view::find_first_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT *__s, size_type __pos=0) const
Definition: libcpp_string_view.h:498
operator==
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator==(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
Definition: libcpp_string_view.h:608
basic_string_view::length
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT
Definition: libcpp_string_view.h:273
basic_string_view::compare
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const _CharT *__s, size_type __n2) const
Definition: libcpp_string_view.h:407
_NOEXCEPT
#define _NOEXCEPT
Definition: RWrap_libcpp_string_view.h:112
basic_string_view::rfind
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
Definition: libcpp_string_view.h:446
basic_string_view::remove_suffix
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_suffix(size_type __n) _NOEXCEPT
Definition: libcpp_string_view.h:325
basic_string_view::swap
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void swap(basic_string_view &__other) _NOEXCEPT
Definition: libcpp_string_view.h:332
operator()
TRObject operator()(const T1 &t1) const
Definition: TRFunctionImport__oprtr.h:14
wstring_view
basic_string_view< wchar_t > wstring_view
Definition: libcpp_string_view.h:789
basic_string_view::size
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT
Definition: libcpp_string_view.h:270
_ROOT_LIBCPP_BEGIN_NAMESPACE_LFTS
#define _ROOT_LIBCPP_BEGIN_NAMESPACE_LFTS
Definition: RWrap_libcpp_string_view.h:49
operator<<
basic_ostream< _CharT, _Traits > & operator<<(basic_ostream< _CharT, _Traits > &__os, basic_string_view< _CharT, _Traits > __sv)
Definition: libcpp_string_view.h:781
basic_string_view::find_last_not_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const
Definition: libcpp_string_view.h:591
basic_string_view::basic_string_view
_LIBCPP_INLINE_VISIBILITY basic_string_view(const basic_string< _CharT, _Traits, _Allocator > &__str) _NOEXCEPT
Definition: libcpp_string_view.h:229
basic_string_view::empty
_LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY empty() const _NOEXCEPT
Definition: libcpp_string_view.h:279
basic_string_view::find_first_not_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
Definition: libcpp_string_view.h:559
basic_string_view::substr
_LIBCPP_CONSTEXPR basic_string_view substr(size_type __pos=0, size_type __n=npos) const
Definition: libcpp_string_view.h:361
basic_string_view::find_first_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT *__s, size_type __pos, size_type __n) const
Definition: libcpp_string_view.h:490
basic_string_view::begin
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT
Definition: libcpp_string_view.h:245
_ROOT_LIBCPP_END_NAMESPACE_LFTS
#define _ROOT_LIBCPP_END_NAMESPACE_LFTS
Definition: RWrap_libcpp_string_view.h:52
basic_string_view::iterator
const_iterator iterator
Definition: libcpp_string_view.h:210
basic_string_view::crbegin
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const _NOEXCEPT
Definition: libcpp_string_view.h:263
basic_string_view::find_last_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
Definition: libcpp_string_view.h:515
basic_string_view::find_first_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
Definition: libcpp_string_view.h:486
basic_string_view::crend
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const _NOEXCEPT
Definition: libcpp_string_view.h:266
basic_string_view::find_first_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
Definition: libcpp_string_view.h:478
basic_string_view::pointer
const _CharT * pointer
Definition: libcpp_string_view.h:205
basic_string_view::operator=
_LIBCPP_INLINE_VISIBILITY basic_string_view & operator=(const basic_string_view &) _NOEXCEPT=default
basic_string_view::rend
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const _NOEXCEPT
Definition: libcpp_string_view.h:260
basic_string_view::difference_type
ptrdiff_t difference_type
Definition: libcpp_string_view.h:214
u16string_view
basic_string_view< char16_t > u16string_view
Definition: libcpp_string_view.h:787
basic_string_view::rbegin
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const _NOEXCEPT
Definition: libcpp_string_view.h:257
basic_string_view::const_reference
const _CharT & const_reference
Definition: libcpp_string_view.h:208
_LIBCPP_BEGIN_NAMESPACE_STD
#define _LIBCPP_BEGIN_NAMESPACE_STD
Definition: RWrap_libcpp_string_view.h:66
basic_string_view::compare
_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
Definition: libcpp_string_view.h:388
basic_string_view::const_reverse_iterator
_VSTD::reverse_iterator< const_iterator > const_reverse_iterator
Definition: libcpp_string_view.h:211
basic_string_view::find
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT *__s, size_type __pos=0) const
Definition: libcpp_string_view.h:437
basic_string_view::value_type
_CharT value_type
Definition: libcpp_string_view.h:204
u32string_view
basic_string_view< char32_t > u32string_view
Definition: libcpp_string_view.h:788
basic_string_view::back
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference back() const
Definition: libcpp_string_view.h:300
basic_string_view::find_last_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT *__s, size_type __pos=npos) const
Definition: libcpp_string_view.h:527
operator>=
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>=(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
Definition: libcpp_string_view.h:755
basic_string_view::basic_string_view
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const basic_string_view &) _NOEXCEPT=default
_LIBCPP_ASSERT
#define _LIBCPP_ASSERT(X, Y)
Definition: RWrap_libcpp_string_view.h:117
basic_string_view::find_last_not_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
Definition: libcpp_string_view.h:576
unary_function
_LIBCPP_CONSTEXPR_AFTER_CXX11
#define _LIBCPP_CONSTEXPR_AFTER_CXX11
Definition: RWrap_libcpp_string_view.h:107
basic_string_view::front
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference front() const
Definition: libcpp_string_view.h:294
basic_string_view::basic_string_view
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view() _NOEXCEPT
Definition: libcpp_string_view.h:219
_LIBCPP_TYPE_VIS_ONLY
#define _LIBCPP_TYPE_VIS_ONLY
Definition: RWrap_libcpp_string_view.h:102
_LIBCPP_CONSTEXPR
#define _LIBCPP_CONSTEXPR
Definition: RWrap_libcpp_string_view.h:72
basic_string_view::find
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(_CharT __c, size_type __pos=0) const _NOEXCEPT
Definition: libcpp_string_view.h:422
basic_string_view::operator[]
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const
Definition: libcpp_string_view.h:283
basic_string_view::find_last_not_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
Definition: libcpp_string_view.h:568
basic_string_view::const_pointer
const _CharT * const_pointer
Definition: libcpp_string_view.h:206
basic_string_view::traits_type
_Traits traits_type
Definition: libcpp_string_view.h:203
basic_string_view::at
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __pos) const
Definition: libcpp_string_view.h:286
basic_string_view::max_size
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
Definition: libcpp_string_view.h:276
basic_string_view::rfind
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT *__s, size_type __pos=npos) const
Definition: libcpp_string_view.h:469
basic_string_view::find
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT *__s, size_type __pos, size_type __n) const
Definition: libcpp_string_view.h:429
basic_string_view::data
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_pointer data() const _NOEXCEPT
Definition: libcpp_string_view.h:306
basic_string_view::find_first_not_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
Definition: libcpp_string_view.h:536
basic_string_view::compare
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(const _CharT *__s) const
Definition: libcpp_string_view.h:395
type
int type
Definition: TGX11.cxx:120
basic_string_view::remove_prefix
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_prefix(size_type __n) _NOEXCEPT
Definition: libcpp_string_view.h:317
basic_string_view::reverse_iterator
const_reverse_iterator reverse_iterator
Definition: libcpp_string_view.h:212
basic_string_view::find_last_not_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT *__s, size_type __pos, size_type __n) const
Definition: libcpp_string_view.h:583
basic_string_view::find_last_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
Definition: libcpp_string_view.h:507
basic_string_view::cend
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT
Definition: libcpp_string_view.h:254
basic_string_view::compare
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
Definition: libcpp_string_view.h:382
basic_string_view::find_last_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT *__s, size_type __pos, size_type __n) const
Definition: libcpp_string_view.h:519
operator<
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
Definition: libcpp_string_view.h:680
basic_string_view::copy
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Definition: libcpp_string_view.h:351
basic_string_view::size_type
size_t size_type
Definition: libcpp_string_view.h:213
operator!=
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator!=(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
Definition: libcpp_string_view.h:649
operator<=
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<=(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
Definition: libcpp_string_view.h:730
basic_string_view::cbegin
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT
Definition: libcpp_string_view.h:251
basic_string_view::find_first_not_of
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
Definition: libcpp_string_view.h:544
basic_string_view::const_iterator
const_pointer const_iterator
Definition: libcpp_string_view.h:209
basic_string_view::clear
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT
Definition: libcpp_string_view.h:310
basic_string_view::__size
size_type __size
Definition: libcpp_string_view.h:600