Logo ROOT   6.14/05
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 
190 //#include <__debug>
191 
192 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
193 #pragma GCC system_header
194 #endif
195 
197 
198  template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
200  public:
201  // types
202  typedef _Traits traits_type;
203  typedef _CharT value_type;
204  typedef const _CharT* pointer;
205  typedef const _CharT* const_pointer;
206  typedef const _CharT& reference;
207  typedef const _CharT& const_reference;
208  typedef const_pointer const_iterator; // See [string.view.iterators]
209  typedef const_iterator iterator;
210  typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
211  typedef const_reverse_iterator reverse_iterator;
212  typedef size_t size_type;
213  typedef ptrdiff_t difference_type;
214  static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
215 
216  // [string.view.cons], construct/copy
218  basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
219 
222 
224  basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
225 
226  template<class _Allocator>
228  basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& __str) _NOEXCEPT
229  : __data (__str.data()), __size(__str.size()) {}
230 
232  basic_string_view(const _CharT* __s, size_type __len)
233  : __data(__s), __size(__len)
234  {
235 // _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): recieved nullptr");
236  }
237 
239  basic_string_view(const _CharT* __s)
240  : __data(__s), __size(_Traits::length(__s)) {}
241 
242  // [string.view.iterators], iterators
244  const_iterator begin() const _NOEXCEPT { return cbegin(); }
245 
247  const_iterator end() const _NOEXCEPT { return cend(); }
248 
250  const_iterator cbegin() const _NOEXCEPT { return __data; }
251 
253  const_iterator cend() const _NOEXCEPT { return __data + __size; }
254 
256  const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
257 
259  const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
260 
262  const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
263 
265  const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
266 
267  // [string.view.capacity], capacity
269  size_type size() const _NOEXCEPT { return __size; }
270 
272  size_type length() const _NOEXCEPT { return __size; }
273 
275  size_type max_size() const _NOEXCEPT { return (_VSTD::numeric_limits<size_type>::max)(); }
276 
278  empty() const _NOEXCEPT { return __size == 0; }
279 
280  // [string.view.access], element access
282  const_reference operator[](size_type __pos) const { return __data[__pos]; }
283 
285  const_reference at(size_type __pos) const
286  {
287  return __pos >= size()
288  ? (throw out_of_range("string_view::at"), __data[0])
289  : __data[__pos];
290  }
291 
293  const_reference front() const
294  {
295  return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
296  }
297 
299  const_reference back() const
300  {
301  return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
302  }
303 
305  const_pointer data() const _NOEXCEPT { return __data; }
306 
307  // [string.view.modifiers], modifiers:
309  void clear() _NOEXCEPT
310  {
311  __data = nullptr;
312  __size = 0;
313  }
314 
316  void remove_prefix(size_type __n) _NOEXCEPT
317  {
318  _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
319  __data += __n;
320  __size -= __n;
321  }
322 
324  void remove_suffix(size_type __n) _NOEXCEPT
325  {
326  _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
327  __size -= __n;
328  }
329 
331  void swap(basic_string_view& __other) _NOEXCEPT
332  {
333  const value_type *__p = __data;
334  __data = __other.__data;
335  __other.__data = __p;
336 
337  size_type __sz = __size;
338  __size = __other.__size;
339  __other.__size = __sz;
340 // _VSTD::swap( __data, __other.__data );
341 // _VSTD::swap( __size, __other.__size );
342  }
343 
344  // [string.view.ops], string operations:
345  template<class _Allocator>
347  _LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const
348  { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
349 
350  size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
351  {
352  if ( __pos > size())
353  throw out_of_range("string_view::copy");
354  size_type __rlen = (_VSTD::min)( __n, size() - __pos );
355  _VSTD::copy_n(begin() + __pos, __rlen, __s );
356  return __rlen;
357  }
358 
360  basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
361  {
362 // if (__pos > size())
363 // throw out_of_range("string_view::substr");
364 // size_type __rlen = _VSTD::min( __n, size() - __pos );
365 // return basic_string_view(data() + __pos, __rlen);
366  return __pos > size()
367  ? throw out_of_range("string_view::substr")
368  : basic_string_view(data() + __pos, (_VSTD::min)(__n, size() - __pos));
369  }
370 
372  {
373  size_type __rlen = (_VSTD::min)( size(), __sv.size());
374  int __retval = _Traits::compare(data(), __sv.data(), __rlen);
375  if ( __retval == 0 ) // first __rlen chars matched
376  __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
377  return __retval;
378  }
379 
381  int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
382  {
383  return substr(__pos1, __n1).compare(__sv);
384  }
385 
387  int compare( size_type __pos1, size_type __n1,
388  basic_string_view _sv, size_type __pos2, size_type __n2) const
389  {
390  return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2));
391  }
392 
394  int compare(const _CharT* __s) const
395  {
396  return compare(basic_string_view(__s));
397  }
398 
400  int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
401  {
402  return substr(__pos1, __n1).compare(basic_string_view(__s));
403  }
404 
406  int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
407  {
408  return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
409  }
410 
411  // find
413  size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
414  {
415  _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr");
416  return _VSTD::__str_find<value_type, size_type, traits_type, npos>
417  (data(), size(), __s.data(), __pos, __s.size());
418  }
419 
421  size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
422  {
423  return _VSTD::__str_find<value_type, size_type, traits_type, npos>
424  (data(), size(), __c, __pos);
425  }
426 
428  size_type find(const _CharT* __s, size_type __pos, size_type __n) const
429  {
430  _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): recieved nullptr");
431  return _VSTD::__str_find<value_type, size_type, traits_type, npos>
432  (data(), size(), __s, __pos, __n);
433  }
434 
436  size_type find(const _CharT* __s, size_type __pos = 0) const
437  {
438  _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): recieved nullptr");
439  return _VSTD::__str_find<value_type, size_type, traits_type, npos>
440  (data(), size(), __s, __pos, traits_type::length(__s));
441  }
442 
443  // rfind
445  size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
446  {
447  _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr");
448  return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
449  (data(), size(), __s.data(), __pos, __s.size());
450  }
451 
453  size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
454  {
455  return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
456  (data(), size(), __c, __pos);
457  }
458 
460  size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const
461  {
462  _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): recieved nullptr");
463  return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
464  (data(), size(), __s, __pos, __n);
465  }
466 
468  size_type rfind(const _CharT* __s, size_type __pos=npos) const
469  {
470  _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): recieved nullptr");
471  return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
472  (data(), size(), __s, __pos, traits_type::length(__s));
473  }
474 
475  // find_first_of
477  size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
478  {
479  _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): recieved nullptr");
480  return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
481  (data(), size(), __s.data(), __pos, __s.size());
482  }
483 
485  size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
486  { return find(__c, __pos); }
487 
489  size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
490  {
491  _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): recieved nullptr");
492  return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
493  (data(), size(), __s, __pos, __n);
494  }
495 
497  size_type find_first_of(const _CharT* __s, size_type __pos=0) const
498  {
499  _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): recieved nullptr");
500  return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
501  (data(), size(), __s, __pos, traits_type::length(__s));
502  }
503 
504  // find_last_of
506  size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
507  {
508  _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): recieved nullptr");
509  return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
510  (data(), size(), __s.data(), __pos, __s.size());
511  }
512 
514  size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
515  { return rfind(__c, __pos); }
516 
518  size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
519  {
520  _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): recieved nullptr");
521  return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
522  (data(), size(), __s, __pos, __n);
523  }
524 
526  size_type find_last_of(const _CharT* __s, size_type __pos=npos) const
527  {
528  _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): recieved nullptr");
529  return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
530  (data(), size(), __s, __pos, traits_type::length(__s));
531  }
532 
533  // find_first_not_of
535  size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
536  {
537  _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): recieved nullptr");
538  return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
539  (data(), size(), __s.data(), __pos, __s.size());
540  }
541 
543  size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
544  {
545  return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
546  (data(), size(), __c, __pos);
547  }
548 
550  size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
551  {
552  _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): recieved nullptr");
553  return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
554  (data(), size(), __s, __pos, __n);
555  }
556 
558  size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const
559  {
560  _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): recieved nullptr");
561  return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
562  (data(), size(), __s, __pos, traits_type::length(__s));
563  }
564 
565  // find_last_not_of
567  size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
568  {
569  _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): recieved nullptr");
570  return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
571  (data(), size(), __s.data(), __pos, __s.size());
572  }
573 
575  size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
576  {
577  return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
578  (data(), size(), __c, __pos);
579  }
580 
582  size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
583  {
584  _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): recieved nullptr");
585  return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
586  (data(), size(), __s, __pos, __n);
587  }
588 
590  size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const
591  {
592  _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): recieved nullptr");
593  return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
594  (data(), size(), __s, __pos, traits_type::length(__s));
595  }
596 
597  private:
598  const value_type* __data;
599  size_type __size;
600  };
601 
602 
603  // [string.view.comparison]
604  // operator ==
605  template<class _CharT, class _Traits>
608  basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
609  {
610  if ( __lhs.size() != __rhs.size()) return false;
611  return __lhs.compare(__rhs) == 0;
612  }
613 
614  template<class _CharT, class _Traits>
617  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
618  {
619  if ( __lhs.size() != __rhs.size()) return false;
620  return __lhs.compare(__rhs) == 0;
621  }
622 
623  template<class _CharT, class _Traits>
625  bool operator==(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
626  basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
627  {
628  if ( __lhs.size() != __rhs.size()) return false;
629  return __lhs.compare(__rhs) == 0;
630  }
631 
632 #ifdef _WIN32
633  template<class _CharT, class _Traits>
636  const _CharT* __rhs) _NOEXCEPT
637  {
639  if ( __lhs.size() != __rhsv.size()) return false;
640  return __lhs.compare(__rhsv) == 0;
641  }
642 #endif
643 
644 
645  // operator !=
646  template<class _CharT, class _Traits>
649  {
650  if ( __lhs.size() != __rhs.size())
651  return true;
652  return __lhs.compare(__rhs) != 0;
653  }
654 
655  template<class _CharT, class _Traits>
658  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
659  {
660  if ( __lhs.size() != __rhs.size())
661  return true;
662  return __lhs.compare(__rhs) != 0;
663  }
664 
665  template<class _CharT, class _Traits>
667  bool operator!=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
668  basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
669  {
670  if ( __lhs.size() != __rhs.size())
671  return true;
672  return __lhs.compare(__rhs) != 0;
673  }
674 
675 
676  // operator <
677  template<class _CharT, class _Traits>
679  bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
680  {
681  return __lhs.compare(__rhs) < 0;
682  }
683 
684  template<class _CharT, class _Traits>
686  bool operator<(basic_string_view<_CharT, _Traits> __lhs,
687  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
688  {
689  return __lhs.compare(__rhs) < 0;
690  }
691 
692  template<class _CharT, class _Traits>
694  bool operator<(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
695  basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
696  {
697  return __lhs.compare(__rhs) < 0;
698  }
699 
700 
701  // operator >
702  template<class _CharT, class _Traits>
705  {
706  return __lhs.compare(__rhs) > 0;
707  }
708 
709  template<class _CharT, class _Traits>
712  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
713  {
714  return __lhs.compare(__rhs) > 0;
715  }
716 
717  template<class _CharT, class _Traits>
719  bool operator>(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
720  basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
721  {
722  return __lhs.compare(__rhs) > 0;
723  }
724 
725 
726  // operator <=
727  template<class _CharT, class _Traits>
729  bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
730  {
731  return __lhs.compare(__rhs) <= 0;
732  }
733 
734  template<class _CharT, class _Traits>
736  bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
737  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
738  {
739  return __lhs.compare(__rhs) <= 0;
740  }
741 
742  template<class _CharT, class _Traits>
744  bool operator<=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
745  basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
746  {
747  return __lhs.compare(__rhs) <= 0;
748  }
749 
750 
751  // operator >=
752  template<class _CharT, class _Traits>
755  {
756  return __lhs.compare(__rhs) >= 0;
757  }
758 
759 
760  template<class _CharT, class _Traits>
763  typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
764  {
765  return __lhs.compare(__rhs) >= 0;
766  }
767 
768  template<class _CharT, class _Traits>
770  bool operator>=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
771  basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
772  {
773  return __lhs.compare(__rhs) >= 0;
774  }
775 
776 
777  // [string.view.io]
778  template<class _CharT, class _Traits>
779  basic_ostream<_CharT, _Traits>&
780  operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv)
781  {
782  return _VSTD::R__put_character_sequence(__os, __sv.data(), __sv.size());
783  }
784 
789 
792 
793 // [string.view.hash]
794 // Shamelessly stolen from <string>
795 template<class _CharT, class _Traits>
796 struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::basic_string_view<_CharT, _Traits> >
797  : public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t>
798 {
799  size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT;
800 };
801 
802 template<class _CharT, class _Traits>
803 size_t
804 hash<std::experimental::basic_string_view<_CharT, _Traits> >::operator()(
805  const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT
806 {
807  return __do_string_hash(__val.data(), __val.data() + __val.size());
808 }
809 
810 #if _LIBCPP_STD_VER > 11
811 template <class _CharT, class _Traits>
812 __quoted_output_proxy<_CharT, const _CharT *, _Traits>
813 quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv,
814  _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
815 {
816  return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
817  ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
818 }
819 #endif
820 
822 
823 #endif // _LIBCPP_LFTS_STRING_VIEW
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
_LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY empty() const _NOEXCEPT
#define _LIBCPP_CONSTEXPR
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT
const _CharT & reference
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void swap(basic_string_view &__other) _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_suffix(size_type __n) _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT *__s, size_type __pos, size_type __n) const
#define _LIBCPP_CONSTEXPR_AFTER_CXX11
#define _LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT
STL namespace.
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const _CharT *__s)
#define _LIBCPP_TYPE_VIS_ONLY
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(_CharT __c, size_type __pos=0) const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT *__s, size_type __pos, size_type __n) const
TRObject operator()(const T1 &t1) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT *__s, size_type __pos=0) const
const _CharT * pointer
#define _LIBCPP_ASSERT(X, Y)
const value_type * __data
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(_CharT __c, size_type __pos=npos) const _NOEXCEPT
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference front() const
_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 bool operator!=(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
_LIBCPP_INLINE_VISIBILITY basic_string_view(const basic_string< _CharT, _Traits, _Allocator > &__str) _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT *__s, size_type __pos, size_type __n) const
basic_string_view< char > string_view
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const _NOEXCEPT
#define _LIBCPP_INLINE_VISIBILITY
const_iterator iterator
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT *__s, size_type __pos=npos) const
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const _NOEXCEPT
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference back() const
_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 bool operator>=(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
_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_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
_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_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
const_reverse_iterator reverse_iterator
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT
#define _ROOT_LIBCPP_BEGIN_NAMESPACE_LFTS
_VSTD::reverse_iterator< const_iterator > const_reverse_iterator
_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 operator[](size_type __pos) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT *__s, size_type __pos=0) const
const _CharT * const_pointer
const_pointer const_iterator
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const _CharT *__s) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
int type
Definition: TGX11.cxx:120
_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 int compare(size_type __pos1, size_type __n1, const _CharT *__s, size_type __n2) const
#define _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(const _CharT *__s) const
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_pointer data() const _NOEXCEPT
Binding & operator=(OUT(*fun)(void))
#define _LIBCPP_EXPLICIT
#define _LIBCPP_END_NAMESPACE_STD
basic_string_view< wchar_t > wstring_view
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view() _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=npos) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator==(basic_string_view< _CharT, _Traits > __lhs, basic_string_view< _CharT, _Traits > __rhs) _NOEXCEPT
_LIBCPP_CONSTEXPR basic_string_view substr(size_type __pos=0, size_type __n=npos) const
basic_ostream< _CharT, _Traits > & R__put_character_sequence(basic_ostream< _CharT, _Traits > &__os, const _CharT *__str, size_t __len)
#define _ROOT_LIBCPP_END_NAMESPACE_LFTS
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT *__s, size_type __pos, size_type __n) const
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __pos) const
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
basic_string_view< char32_t > u32string_view
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const _CharT *__s, size_type __len)
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT *__s, size_type __pos, size_type __n) const
basic_string_view< char16_t > u16string_view
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const _NOEXCEPT
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_prefix(size_type __n) _NOEXCEPT