PMDK C++ bindings  1.13.0-git107.g7e59f08f
This is the C++ bindings documentation for PMDK's libpmemobj.
string_view.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: BSD-3-Clause
2 /* Copyright 2020-2021, Intel Corporation */
3 
9 #ifndef LIBPMEMOBJ_CPP_STRING_VIEW
10 #define LIBPMEMOBJ_CPP_STRING_VIEW
11 
12 #include <algorithm>
13 #include <limits>
14 #include <stdexcept>
15 #include <string>
16 #include <utility>
17 
18 #if __cpp_lib_string_view
19 #include <string_view>
20 #endif
21 
22 namespace pmem
23 {
24 
25 namespace obj
26 {
27 
28 #if __cpp_lib_string_view
29 
30 template <typename CharT, typename Traits = std::char_traits<CharT>>
31 using basic_string_view = std::basic_string_view<CharT, Traits>;
33 using wstring_view = std::basic_string_view<wchar_t>;
34 using u16string_view = std::basic_string_view<char16_t>;
35 using u32string_view = std::basic_string_view<char32_t>;
36 
37 #else
38 
47 template <typename CharT, typename Traits = std::char_traits<CharT>>
49 public:
50  /* Member types */
51  using traits_type = Traits;
52  using value_type = CharT;
53  using size_type = std::size_t;
54  using difference_type = std::ptrdiff_t;
55  using reference = value_type &;
56  using const_reference = const value_type &;
57  using pointer = value_type *;
58  using const_pointer = const value_type *;
59  using const_iterator = const_pointer;
60  using iterator = const_iterator;
61  using reverse_iterator = std::reverse_iterator<const_iterator>;
62  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
63 
64  static constexpr const size_type npos =
65  (std::numeric_limits<size_type>::max)();
66 
67  constexpr basic_string_view() noexcept;
68  constexpr basic_string_view(const CharT *data, size_type size);
69  constexpr basic_string_view(const std::basic_string<CharT, Traits> &s);
70  constexpr basic_string_view(const CharT *data);
71 
76  constexpr basic_string_view(const basic_string_view &rhs) noexcept =
77  default;
78 
85  operator=(const basic_string_view &rhs) noexcept = default;
86 
87  constexpr const_iterator begin() const noexcept;
88  constexpr const_iterator cbegin() const noexcept;
89  constexpr const_iterator end() const noexcept;
90  constexpr const_iterator cend() const noexcept;
91  constexpr const_reverse_iterator rbegin() const noexcept;
92  constexpr const_reverse_iterator crbegin() const noexcept;
93  constexpr const_reverse_iterator rend() const noexcept;
94  constexpr const_reverse_iterator crend() const noexcept;
95 
96  constexpr const CharT *data() const noexcept;
97  constexpr size_type size() const noexcept;
98  constexpr size_type length() const noexcept;
99  constexpr bool empty() const noexcept;
100  constexpr size_type max_size() const noexcept;
101 
102  const CharT &at(size_type pos) const;
103  constexpr const CharT &operator[](size_type pos) const noexcept;
104  constexpr const_reference front() const noexcept;
105  constexpr const_reference back() const noexcept;
106 
107  void remove_prefix(size_type n);
108  void remove_suffix(size_type n);
109  void swap(basic_string_view &v) noexcept;
110 
111  constexpr basic_string_view substr(size_type pos = 0,
112  size_type count = npos) const;
113  size_type copy(CharT *dest, size_type count, size_type pos = 0) const;
114  inline int compare(size_type pos1, size_type n1,
115  basic_string_view sv) const;
116  inline int compare(size_type pos1, size_type n1, basic_string_view sv,
117  size_type pos2, size_type n2) const;
118  inline int compare(const CharT *s) const noexcept;
119  inline int compare(size_type pos1, size_type n1, const CharT *s) const;
120  inline int compare(size_type pos1, size_type n1, const CharT *s,
121  size_type n2) const;
122  int compare(const basic_string_view &other) const noexcept;
123 
124  size_type find(basic_string_view str, size_type pos = 0) const noexcept;
125  size_type find(CharT ch, size_type pos = 0) const noexcept;
126  size_type find(const CharT *s, size_type pos = 0) const;
127  size_type find(const CharT *s, size_type pos, size_type count) const;
128 
129  size_type rfind(basic_string_view str, size_type pos = npos) const
130  noexcept;
131  size_type rfind(const CharT *s, size_type pos, size_type count) const;
132  size_type rfind(const CharT *s, size_type pos = npos) const;
133  size_type rfind(CharT ch, size_type pos = npos) const noexcept;
134  size_type find_first_of(basic_string_view str, size_type pos = 0) const
135  noexcept;
136  size_type find_first_of(const CharT *s, size_type pos,
137  size_type count) const;
138  size_type find_first_of(const CharT *s, size_type pos = 0) const;
139  size_type find_first_of(CharT ch, size_type pos = 0) const noexcept;
141  size_type pos = 0) const noexcept;
142  size_type find_first_not_of(const CharT *s, size_type pos,
143  size_type count) const;
144  size_type find_first_not_of(const CharT *s, size_type pos = 0) const;
145  size_type find_first_not_of(CharT ch, size_type pos = 0) const noexcept;
147  size_type pos = npos) const noexcept;
148  size_type find_last_of(const CharT *s, size_type pos,
149  size_type count) const;
150  size_type find_last_of(const CharT *s, size_type pos = npos) const;
151  size_type find_last_of(CharT ch, size_type pos = npos) const noexcept;
153  size_type pos = npos) const noexcept;
154  size_type find_last_not_of(const CharT *s, size_type pos,
155  size_type count) const;
156  size_type find_last_not_of(const CharT *s, size_type pos = npos) const;
157  size_type find_last_not_of(CharT ch, size_type pos = npos) const
158  noexcept;
159 
160 private:
161  const value_type *data_;
162  size_type size_;
163 };
164 
170 
176 
182 
188 
192 template <typename CharT, typename Traits>
193 constexpr inline basic_string_view<CharT, Traits>::basic_string_view() noexcept
194  : data_(nullptr), size_(0)
195 {
196 }
197 
205 template <typename CharT, typename Traits>
207  const CharT *data, size_type size)
208  : data_(data), size_(size)
209 {
210 }
211 
217 template <typename CharT, typename Traits>
219  const std::basic_string<CharT, Traits> &s)
220  : data_(s.c_str()), size_(s.size())
221 {
222 }
223 
231 template <typename CharT, typename Traits>
233  const CharT *data)
234  : data_(data), size_(Traits::length(data))
235 {
236 }
237 
243 template <typename CharT, typename Traits>
246 {
247  return cbegin();
248 }
249 
255 template <typename CharT, typename Traits>
258 {
259  return data_;
260 }
261 
269 template <typename CharT, typename Traits>
272 {
273  return cend();
274 }
275 
283 template <typename CharT, typename Traits>
286 {
287  return data_ + size_;
288 }
289 
297 template <typename CharT, typename Traits>
300 {
301  return reverse_iterator(cend());
302 }
303 
311 template <typename CharT, typename Traits>
314 {
315  return reverse_iterator(cend());
316 }
317 
327 template <typename CharT, typename Traits>
330 {
331  return reverse_iterator(cbegin());
332 }
333 
343 template <typename CharT, typename Traits>
346 {
347  return reverse_iterator(cbegin());
348 }
349 
357 template <typename CharT, typename Traits>
358 constexpr inline const CharT *
360 {
361  return data_;
362 }
363 
369 template <typename CharT, typename Traits>
370 constexpr inline bool
372 {
373  return size() == 0;
374 }
375 
382 template <typename CharT, typename Traits>
383 constexpr inline typename basic_string_view<CharT, Traits>::size_type
385 {
386  return (std::numeric_limits<size_type>::max)();
387 }
388 
395 template <typename CharT, typename Traits>
396 constexpr inline typename basic_string_view<CharT, Traits>::size_type
398 {
399  return size_;
400 }
401 
407 template <typename CharT, typename Traits>
408 constexpr inline typename basic_string_view<CharT, Traits>::size_type
410 {
411  return size_;
412 }
413 
419 template <typename CharT, typename Traits>
420 constexpr inline const CharT &
422 {
423  return data()[pos];
424 }
425 
434 template <typename CharT, typename Traits>
435 inline const CharT &
437 {
438  if (pos >= size())
439  throw std::out_of_range("Accessing a position out of bounds!");
440  return data()[pos];
441 }
442 
449 template <typename CharT, typename Traits>
450 constexpr inline const CharT &
452 {
453  return operator[](size() - 1);
454 }
455 
462 template <typename CharT, typename Traits>
463 constexpr inline const CharT &
465 {
466  return operator[](0);
467 }
468 
475 template <typename CharT, typename Traits>
476 void
478 {
479  data_ += n;
480  size_ -= n;
481 }
482 
489 template <typename CharT, typename Traits>
490 void
492 {
493  size_ -= n;
494 }
495 
501 template <typename CharT, typename Traits>
502 void
505 {
506  std::swap(data_, v.data_);
507  std::swap(size_, v.size_);
508 }
509 
519 template <typename CharT, typename Traits>
522  size_type pos) const noexcept
523 {
524  return find(str.data(), pos, str.size());
525 }
526 
536 template <typename CharT, typename Traits>
538 basic_string_view<CharT, Traits>::find(CharT ch, size_type pos) const noexcept
539 {
540  return find(&ch, pos, 1);
541 }
542 
554 template <typename CharT, typename Traits>
556 basic_string_view<CharT, Traits>::find(const CharT *s, size_type pos,
557  size_type count) const
558 {
559  auto sz = size();
560 
561  if (pos > sz)
562  return npos;
563 
564  if (count == 0)
565  return pos;
566 
567  while (pos + count <= sz) {
568  auto found = traits_type::find(data() + pos, sz - pos, s[0]);
569  if (!found)
570  return npos;
571  pos = static_cast<size_type>(std::distance(data(), found));
572  if (traits_type::compare(found, s, count) == 0) {
573  return pos;
574  }
575  ++pos;
576  }
577  return npos;
578 }
579 
590 template <typename CharT, typename Traits>
592 basic_string_view<CharT, Traits>::find(const CharT *s, size_type pos) const
593 {
594  return find(s, pos, traits_type::length(s));
595 }
596 
607 template <typename CharT, typename Traits>
610  size_type pos) const noexcept
611 {
612  return rfind(str.data(), pos, str.size());
613 }
614 
631 template <typename CharT, typename Traits>
633 basic_string_view<CharT, Traits>::rfind(const CharT *s, size_type pos,
634  size_type count) const
635 {
636  if (count <= size()) {
637  pos = (std::min)(size() - count, pos);
638  do {
639  if (traits_type::compare(data() + pos, s, count) == 0)
640  return pos;
641  } while (pos-- > 0);
642  }
643  return npos;
644 }
645 
658 template <typename CharT, typename Traits>
660 basic_string_view<CharT, Traits>::rfind(const CharT *s, size_type pos) const
661 {
662  return rfind(s, pos, traits_type::length(s));
663 }
664 
676 template <typename CharT, typename Traits>
678 basic_string_view<CharT, Traits>::rfind(CharT ch, size_type pos) const noexcept
679 {
680  return rfind(&ch, pos, 1);
681 }
682 
692 template <typename CharT, typename Traits>
695  size_type pos) const noexcept
696 {
697  return find_first_of(str.data(), pos, str.size());
698 }
699 
713 template <typename CharT, typename Traits>
716  size_type count) const
717 {
718  size_type first_of = npos;
719  for (const CharT *c = s; c != s + count; ++c) {
720  size_type found = find(*c, pos);
721  if (found != npos && found < first_of)
722  first_of = found;
723  }
724  return first_of;
725 }
726 
739 template <typename CharT, typename Traits>
742  size_type pos) const
743 {
744  return find_first_of(s, pos, traits_type::length(s));
745 }
746 
756 template <typename CharT, typename Traits>
759  noexcept
760 {
761  return find(ch, pos);
762 }
763 
773 template <typename CharT, typename Traits>
776  size_type pos) const
777  noexcept
778 {
779  return find_first_not_of(str.data(), pos, str.size());
780 }
781 
795 template <typename CharT, typename Traits>
798  size_type pos,
799  size_type count) const
800 {
801  if (pos >= size())
802  return npos;
803 
804  for (auto it = cbegin() + pos; it != cend(); ++it)
805  if (!traits_type::find(s, count, *it))
806  return static_cast<size_type>(
807  std::distance(cbegin(), it));
808  return npos;
809 }
810 
823 template <typename CharT, typename Traits>
826  size_type pos) const
827 {
828  return find_first_not_of(s, pos, traits_type::length(s));
829 }
830 
840 template <typename CharT, typename Traits>
843  size_type pos) const
844  noexcept
845 {
846  return find_first_not_of(&ch, pos, 1);
847 }
848 
858 template <typename CharT, typename Traits>
861  size_type pos) const noexcept
862 {
863  return find_last_of(str.data(), pos, str.size());
864 }
865 
879 template <typename CharT, typename Traits>
882  size_type count) const
883 {
884  if (size() == 0 || count == 0)
885  return npos;
886 
887  bool found = false;
888  size_type last_of = 0;
889  for (const CharT *c = s; c != s + count; ++c) {
890  size_type position = rfind(*c, pos);
891  if (position != npos) {
892  found = true;
893  if (position > last_of)
894  last_of = position;
895  }
896  }
897  if (!found)
898  return npos;
899  return last_of;
900 }
901 
914 template <typename CharT, typename Traits>
917  size_type pos) const
918 {
919  return find_last_of(s, pos, traits_type::length(s));
920 }
921 
931 template <typename CharT, typename Traits>
934  noexcept
935 {
936  return rfind(ch, pos);
937 }
938 
948 template <typename CharT, typename Traits>
951  size_type pos) const noexcept
952 {
953  return find_last_not_of(str.data(), pos, str.size());
954 }
955 
969 template <typename CharT, typename Traits>
972  size_type pos,
973  size_type count) const
974 {
975  if (size() > 0) {
976  pos = (std::min)(pos, size() - 1);
977  do {
978  if (!traits_type::find(s, count, *(data() + pos)))
979  return pos;
980 
981  } while (pos-- > 0);
982  }
983  return npos;
984 }
985 
998 template <typename CharT, typename Traits>
1001  size_type pos) const
1002 {
1003  return find_last_not_of(s, pos, traits_type::length(s));
1004 }
1005 
1015 template <typename CharT, typename Traits>
1018  size_type pos) const noexcept
1019 {
1020  return find_last_not_of(&ch, pos, 1);
1021 }
1022 
1034 template <typename CharT, typename Traits>
1036 basic_string_view<CharT, Traits>::substr(size_type pos, size_type count) const
1037 {
1038  return pos > size()
1039  ? throw std::out_of_range("string_view::substr")
1040  : basic_string_view(data() + pos,
1041  (std::min)(count, size() - pos));
1042 }
1043 
1056 template <typename CharT, typename Traits>
1058 basic_string_view<CharT, Traits>::copy(CharT *dest, size_type count,
1059  size_type pos) const
1060 {
1061  if (pos > size())
1062  throw std::out_of_range("string_view::copy");
1063  size_type rlen = (std::min)(count, size() - pos);
1064  Traits::copy(dest, data() + pos, rlen);
1065  return rlen;
1066 }
1067 
1079 template <typename CharT, typename Traits>
1080 inline int
1081 basic_string_view<CharT, Traits>::compare(size_type pos1, size_type n1,
1082  basic_string_view sv) const
1083 {
1084  return substr(pos1, n1).compare(sv);
1085 }
1086 
1100 template <typename CharT, typename Traits>
1101 inline int
1102 basic_string_view<CharT, Traits>::compare(size_type pos1, size_type n1,
1103  basic_string_view sv, size_type pos2,
1104  size_type n2) const
1105 {
1106  return substr(pos1, n1).compare(sv.substr(pos2, n2));
1107 }
1108 
1118 template <typename CharT, typename Traits>
1119 inline int
1120 basic_string_view<CharT, Traits>::compare(const CharT *s) const noexcept
1121 {
1122  return compare(basic_string_view(s));
1123 }
1124 
1136 template <typename CharT, typename Traits>
1137 inline int
1138 basic_string_view<CharT, Traits>::compare(size_type pos1, size_type n1,
1139  const CharT *s) const
1140 {
1141  return substr(pos1, n1).compare(basic_string_view(s));
1142 }
1143 
1156 template <typename CharT, typename Traits>
1157 inline int
1158 basic_string_view<CharT, Traits>::compare(size_type pos1, size_type n1,
1159  const CharT *s, size_type n2) const
1160 {
1161  return substr(pos1, n1).compare(basic_string_view(s, n2));
1162 }
1163 
1172 template <typename CharT, typename Traits>
1173 inline int
1175  noexcept
1176 {
1177  int ret = Traits::compare(data(), other.data(),
1178  (std::min)(size(), other.size()));
1179  if (ret != 0)
1180  return ret;
1181  if (size() < other.size())
1182  return -1;
1183  if (size() > other.size())
1184  return 1;
1185  return 0;
1186 }
1187 
1192 template <class CharT, class Traits>
1193 constexpr bool
1196 {
1197  return (lhs.size() != rhs.size() ? false : lhs.compare(rhs) == 0);
1198 }
1199 
1204 template <class CharT, class Traits>
1205 constexpr bool
1208  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1209 {
1210  return (lhs.size() != rhs.size() ? false : lhs.compare(rhs) == 0);
1211 }
1212 
1217 template <class CharT, class Traits>
1218 constexpr bool
1220  typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1222 {
1223  return (lhs.size() != rhs.size() ? false : lhs.compare(rhs) == 0);
1224 }
1225 
1230 template <class CharT, class Traits>
1231 constexpr bool
1234 {
1235  return (lhs.size() != rhs.size() ? true : lhs.compare(rhs) != 0);
1236 }
1237 
1242 template <class CharT, class Traits>
1243 constexpr bool
1245  typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1247 {
1248  return (lhs.size() != rhs.size() ? true : lhs.compare(rhs) != 0);
1249 }
1250 
1255 template <class CharT, class Traits>
1256 constexpr bool
1259  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1260 {
1261  return (lhs.size() != rhs.size() ? true : lhs.compare(rhs) != 0);
1262 }
1263 
1268 template <class CharT, class Traits>
1269 constexpr bool
1272 {
1273  return lhs.compare(rhs) < 0;
1274 }
1275 
1280 template <class CharT, class Traits>
1281 constexpr bool
1282 operator<(typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1284 {
1285  return lhs.compare(rhs) < 0;
1286 }
1287 
1292 template <class CharT, class Traits>
1293 constexpr bool
1295  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1296 {
1297  return lhs.compare(rhs) < 0;
1298 }
1299 
1304 template <class CharT, class Traits>
1305 constexpr bool
1308 {
1309  return lhs.compare(rhs) <= 0;
1310 }
1311 
1316 template <class CharT, class Traits>
1317 constexpr bool
1318 operator<=(
1320  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1321 {
1322  return lhs.compare(rhs) <= 0;
1323 }
1324 
1329 template <class CharT, class Traits>
1330 constexpr bool
1331 operator<=(
1332  typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1334 {
1335  return lhs.compare(rhs) <= 0;
1336 }
1337 
1342 template <class CharT, class Traits>
1343 constexpr bool
1346 {
1347  return lhs.compare(rhs) > 0;
1348 }
1349 
1354 template <class CharT, class Traits>
1355 constexpr bool
1356 operator>(typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1358 {
1359  return lhs.compare(rhs) > 0;
1360 }
1361 
1366 template <class CharT, class Traits>
1367 constexpr bool
1369  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1370 {
1371  return lhs.compare(rhs) > 0;
1372 }
1373 
1378 template <class CharT, class Traits>
1379 constexpr bool
1382 {
1383  return lhs.compare(rhs) >= 0;
1384 }
1385 
1390 template <class CharT, class Traits>
1391 constexpr bool
1393  typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1395 {
1396  return lhs.compare(rhs) >= 0;
1397 }
1398 
1403 template <class CharT, class Traits>
1404 constexpr bool
1407  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1408 {
1409  return lhs.compare(rhs) >= 0;
1410 }
1411 #endif
1412 
1413 } /* namespace obj */
1414 } /* namespace pmem */
1415 
1416 #endif /* LIBPMEMOBJ_CPP_STRING_VIEW */
Our partial std::string_view implementation.
Definition: string_view.hpp:48
constexpr const_reverse_iterator crbegin() const noexcept
Returns a reverse_iterator to the character following the last character of the view (reverse beginni...
Definition: string_view.hpp:313
constexpr const_iterator begin() const noexcept
Returns an iterator to the first character of the view.
Definition: string_view.hpp:245
constexpr bool operator>(basic_string_view< CharT, Traits > lhs, basic_string_view< CharT, Traits > rhs)
Non-member greater than operator.
Definition: string_view.hpp:1344
constexpr size_type max_size() const noexcept
Returns the largest possible number of char-like objects that can be referred to by a basic_string_vi...
Definition: string_view.hpp:384
void swap(basic_string_view &v) noexcept
Exchanges the view with that of v.
Definition: string_view.hpp:503
constexpr size_type size() const noexcept
Returns count of characters stored in this pmem::obj::string_view data.
Definition: string_view.hpp:397
size_type find(basic_string_view str, size_type pos=0) const noexcept
Finds the first substring equal to str.
Definition: string_view.hpp:521
void remove_prefix(size_type n)
Moves the start of the view forward by n characters.
Definition: string_view.hpp:477
size_type find_first_not_of(basic_string_view str, size_type pos=0) const noexcept
Finds the first character equal to none of the characters in str.
Definition: string_view.hpp:775
constexpr bool operator>(typename std::common_type< basic_string_view< CharT, Traits >>::type lhs, basic_string_view< CharT, Traits > rhs)
Non-member greater than operator.
Definition: string_view.hpp:1356
int compare(size_type pos1, size_type n1, basic_string_view sv) const
Compares two character sequences.
Definition: string_view.hpp:1081
constexpr const_reverse_iterator crend() const noexcept
Returns a reverse_iterator to the first character of the view.
Definition: string_view.hpp:345
constexpr const_iterator cbegin() const noexcept
Returns an iterator to the first character of the view.
Definition: string_view.hpp:257
constexpr size_type length() const noexcept
Returns count of characters stored in this pmem::obj::string_view data.
Definition: string_view.hpp:409
constexpr bool operator>(basic_string_view< CharT, Traits > lhs, typename std::common_type< basic_string_view< CharT, Traits >>::type rhs)
Non-member greater than operator.
Definition: string_view.hpp:1368
size_type find_last_not_of(basic_string_view str, size_type pos=npos) const noexcept
Finds the last character equal to none of the characters in str.
Definition: string_view.hpp:950
constexpr bool operator!=(basic_string_view< CharT, Traits > lhs, basic_string_view< CharT, Traits > rhs)
Non-member not equal operator.
Definition: string_view.hpp:1232
constexpr bool operator!=(basic_string_view< CharT, Traits > lhs, typename std::common_type< basic_string_view< CharT, Traits >>::type rhs)
Non-member not equal operator.
Definition: string_view.hpp:1257
constexpr const_reverse_iterator rbegin() const noexcept
Returns a reverse_iterator to the character following the last character of the view (reverse beginni...
Definition: string_view.hpp:299
void remove_suffix(size_type n)
Moves the end of the view back by n characters.
Definition: string_view.hpp:491
constexpr bool empty() const noexcept
Returns that view is empty or not.
Definition: string_view.hpp:371
size_type find_last_of(basic_string_view str, size_type pos=npos) const noexcept
Finds the last character equal to any of the characters in str.
Definition: string_view.hpp:860
constexpr bool operator>=(basic_string_view< CharT, Traits > lhs, typename std::common_type< basic_string_view< CharT, Traits >>::type rhs)
Non-member greater or equal operator.
Definition: string_view.hpp:1405
const CharT & at(size_type pos) const
Returns reference to the character at position.
Definition: string_view.hpp:436
size_type rfind(basic_string_view str, size_type pos=npos) const noexcept
Finds the last substring equal to str.
Definition: string_view.hpp:609
constexpr const_reverse_iterator rend() const noexcept
Returns a reverse_iterator to the first character of the view.
Definition: string_view.hpp:329
constexpr const_iterator cend() const noexcept
Returns an iterator to the character following the last character of the view.
Definition: string_view.hpp:285
constexpr bool operator==(basic_string_view< CharT, Traits > lhs, basic_string_view< CharT, Traits > rhs)
Non-member equal operator.
Definition: string_view.hpp:1194
size_type copy(CharT *dest, size_type count, size_type pos=0) const
Copies the substring [pos, pos + rcount) to the character array pointed to by dest,...
Definition: string_view.hpp:1058
constexpr basic_string_view substr(size_type pos=0, size_type count=npos) const
Returns a view of the substring [pos, pos + rcount), where rcount is the smaller of count and size() ...
Definition: string_view.hpp:1036
constexpr bool operator>=(basic_string_view< CharT, Traits > lhs, basic_string_view< CharT, Traits > rhs)
Non-member greater or equal operator.
Definition: string_view.hpp:1380
constexpr const_reference front() const noexcept
Returns reference to the first character in the view.
Definition: string_view.hpp:464
size_type find_first_of(basic_string_view str, size_type pos=0) const noexcept
Finds the first character equal to any of the characters in str.
Definition: string_view.hpp:694
constexpr bool operator==(basic_string_view< CharT, Traits > lhs, typename std::common_type< basic_string_view< CharT, Traits >>::type rhs)
Non-member equal operator.
Definition: string_view.hpp:1206
constexpr const_iterator end() const noexcept
Returns an iterator to the character following the last character of the view.
Definition: string_view.hpp:271
constexpr const_reference back() const noexcept
Returns reference to the last character in the view.
Definition: string_view.hpp:451
constexpr const CharT * data() const noexcept
Returns pointer to data stored in this pmem::obj::string_view.
Definition: string_view.hpp:359
constexpr basic_string_view() noexcept
Default constructor with empty data.
Definition: string_view.hpp:193
constexpr bool operator==(typename std::common_type< basic_string_view< CharT, Traits >>::type lhs, basic_string_view< CharT, Traits > rhs)
Non-member equal operator.
Definition: string_view.hpp:1219
constexpr bool operator>=(typename std::common_type< basic_string_view< CharT, Traits >>::type lhs, basic_string_view< CharT, Traits > rhs)
Non-member greater or equal operator.
Definition: string_view.hpp:1392
constexpr bool operator!=(typename std::common_type< basic_string_view< CharT, Traits >>::type lhs, basic_string_view< CharT, Traits > rhs)
Non-member not equal operator.
Definition: string_view.hpp:1244
Persistent string container with std::basic_string compatible interface.
Definition: basic_string.hpp:48
basic_string_view< wchar_t > wstring_view
The wide char specialization.
Definition: string_view.hpp:175
basic_string_view< char16_t > u16string_view
The char16 specialization.
Definition: string_view.hpp:181
basic_string_view< char32_t > u32string_view
The char32 specialization.
Definition: string_view.hpp:187
basic_string_view< char > string_view
The most typical string_view usage - the char specialization.
Definition: string_view.hpp:169
Persistent memory namespace.
Definition: allocation_flag.hpp:15
pmem::obj::array< T, N >::const_iterator cbegin(const pmem::obj::array< T, N > &a)
Non-member cbegin.
Definition: array.hpp:797
bool operator<=(const array< T, N > &lhs, const array< T, N > &rhs)
Non-member less or equal operator.
Definition: array.hpp:786
bool operator<(const array< T, N > &lhs, const array< T, N > &rhs)
Non-member less than operator.
Definition: array.hpp:752
pmem::obj::array< T, N >::const_iterator cend(const pmem::obj::array< T, N > &a)
Non-member cend.
Definition: array.hpp:808