PMDK C++ bindings  1.12-git53.g67ba2be4
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, 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>;
32 using string_view = std::string_view;
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 
45 template <typename CharT, typename Traits = std::char_traits<CharT>>
47 public:
48  /* Member types */
49  using traits_type = Traits;
50  using value_type = CharT;
51  using size_type = std::size_t;
52  using difference_type = std::ptrdiff_t;
53  using reference = value_type &;
54  using const_reference = const value_type &;
55  using pointer = value_type *;
56  using const_pointer = const value_type *;
57  using const_iterator = const_pointer;
58  using iterator = const_iterator;
59  using reverse_iterator = std::reverse_iterator<const_iterator>;
60  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
61 
62  static constexpr const size_type npos =
63  (std::numeric_limits<size_type>::max)();
64 
65  constexpr basic_string_view() noexcept;
66  constexpr basic_string_view(const CharT *data, size_type size);
67  constexpr basic_string_view(const std::basic_string<CharT, Traits> &s);
68  constexpr basic_string_view(const CharT *data);
69 
70  constexpr basic_string_view(const basic_string_view &rhs) noexcept =
71  default;
73  operator=(const basic_string_view &rhs) noexcept = default;
74 
75  constexpr const_iterator begin() const noexcept;
76  constexpr const_iterator cbegin() const noexcept;
77  constexpr const_iterator end() const noexcept;
78  constexpr const_iterator cend() const noexcept;
79  constexpr const_reverse_iterator rbegin() const noexcept;
80  constexpr const_reverse_iterator crbegin() const noexcept;
81  constexpr const_reverse_iterator rend() const noexcept;
82  constexpr const_reverse_iterator crend() const noexcept;
83 
84  constexpr const CharT *data() const noexcept;
85  constexpr size_type size() const noexcept;
86  constexpr size_type length() const noexcept;
87  constexpr bool empty() const noexcept;
88  constexpr size_type max_size() const noexcept;
89 
90  const CharT &at(size_type pos) const;
91  constexpr const CharT &operator[](size_type pos) const noexcept;
92  constexpr const_reference front() const noexcept;
93  constexpr const_reference back() const noexcept;
94 
95  void remove_prefix(size_type n);
96  void remove_suffix(size_type n);
97  void swap(basic_string_view &v) noexcept;
98 
99  constexpr basic_string_view substr(size_type pos = 0,
100  size_type count = npos) const;
101  size_type copy(CharT *dest, size_type count, size_type pos = 0) const;
102  inline int compare(size_type pos1, size_type n1,
103  basic_string_view sv) const;
104  inline int compare(size_type pos1, size_type n1, basic_string_view sv,
105  size_type pos2, size_type n2) const;
106  inline int compare(const CharT *s) const noexcept;
107  inline int compare(size_type pos1, size_type n1, const CharT *s) const;
108  inline int compare(size_type pos1, size_type n1, const CharT *s,
109  size_type n2) const;
110  int compare(const basic_string_view &other) const noexcept;
111 
112  size_type find(basic_string_view str, size_type pos = 0) const noexcept;
113  size_type find(CharT ch, size_type pos = 0) const noexcept;
114  size_type find(const CharT *s, size_type pos = 0) const;
115  size_type find(const CharT *s, size_type pos, size_type count) const;
116 
117  size_type rfind(basic_string_view str, size_type pos = npos) const
118  noexcept;
119  size_type rfind(const CharT *s, size_type pos, size_type count) const;
120  size_type rfind(const CharT *s, size_type pos = npos) const;
121  size_type rfind(CharT ch, size_type pos = npos) const noexcept;
122  size_type find_first_of(basic_string_view str, size_type pos = 0) const
123  noexcept;
124  size_type find_first_of(const CharT *s, size_type pos,
125  size_type count) const;
126  size_type find_first_of(const CharT *s, size_type pos = 0) const;
127  size_type find_first_of(CharT ch, size_type pos = 0) const noexcept;
128  size_type find_first_not_of(basic_string_view str,
129  size_type pos = 0) const noexcept;
130  size_type find_first_not_of(const CharT *s, size_type pos,
131  size_type count) const;
132  size_type find_first_not_of(const CharT *s, size_type pos = 0) const;
133  size_type find_first_not_of(CharT ch, size_type pos = 0) const noexcept;
134  size_type find_last_of(basic_string_view str,
135  size_type pos = npos) const noexcept;
136  size_type find_last_of(const CharT *s, size_type pos,
137  size_type count) const;
138  size_type find_last_of(const CharT *s, size_type pos = npos) const;
139  size_type find_last_of(CharT ch, size_type pos = npos) const noexcept;
140  size_type find_last_not_of(basic_string_view str,
141  size_type pos = npos) const noexcept;
142  size_type find_last_not_of(const CharT *s, size_type pos,
143  size_type count) const;
144  size_type find_last_not_of(const CharT *s, size_type pos = npos) const;
145  size_type find_last_not_of(CharT ch, size_type pos = npos) const
146  noexcept;
147 
148 private:
149  const value_type *data_;
150  size_type size_;
151 };
152 
157 
161 template <typename CharT, typename Traits>
163  : data_(nullptr), size_(0)
164 {
165 }
166 
174 template <typename CharT, typename Traits>
176  const CharT *data, size_type size)
177  : data_(data), size_(size)
178 {
179 }
180 
186 template <typename CharT, typename Traits>
188  const std::basic_string<CharT, Traits> &s)
189  : data_(s.c_str()), size_(s.size())
190 {
191 }
192 
200 template <typename CharT, typename Traits>
202  const CharT *data)
203  : data_(data), size_(Traits::length(data))
204 {
205 }
206 
212 template <typename CharT, typename Traits>
213 constexpr typename basic_string_view<CharT, Traits>::const_iterator
215 {
216  return cbegin();
217 }
218 
224 template <typename CharT, typename Traits>
225 constexpr typename basic_string_view<CharT, Traits>::const_iterator
227 {
228  return data_;
229 }
230 
238 template <typename CharT, typename Traits>
239 constexpr typename basic_string_view<CharT, Traits>::const_iterator
241 {
242  return cend();
243 }
244 
252 template <typename CharT, typename Traits>
253 constexpr typename basic_string_view<CharT, Traits>::const_iterator
255 {
256  return data_ + size_;
257 }
258 
259 template <typename CharT, typename Traits>
260 constexpr typename basic_string_view<CharT, Traits>::const_reverse_iterator
262 {
263  return reverse_iterator(cend());
264 }
265 
266 template <typename CharT, typename Traits>
267 constexpr typename basic_string_view<CharT, Traits>::const_reverse_iterator
268 basic_string_view<CharT, Traits>::crbegin() const noexcept
269 {
270  return reverse_iterator(cend());
271 }
272 
273 template <typename CharT, typename Traits>
274 constexpr typename basic_string_view<CharT, Traits>::const_reverse_iterator
275 basic_string_view<CharT, Traits>::rend() const noexcept
276 {
277  return reverse_iterator(cbegin());
278 }
279 
280 template <typename CharT, typename Traits>
281 constexpr typename basic_string_view<CharT, Traits>::const_reverse_iterator
282 basic_string_view<CharT, Traits>::crend() const noexcept
283 {
284  return reverse_iterator(cbegin());
285 }
286 
294 template <typename CharT, typename Traits>
295 constexpr inline const CharT *
297 {
298  return data_;
299 }
300 
306 template <typename CharT, typename Traits>
307 constexpr inline bool
309 {
310  return size() == 0;
311 }
312 
319 template <typename CharT, typename Traits>
320 constexpr inline typename basic_string_view<CharT, Traits>::size_type
322 {
323  return (std::numeric_limits<size_type>::max)();
324 }
325 
332 template <typename CharT, typename Traits>
333 constexpr inline typename basic_string_view<CharT, Traits>::size_type
335 {
336  return size_;
337 }
338 
344 template <typename CharT, typename Traits>
345 constexpr inline typename basic_string_view<CharT, Traits>::size_type
347 {
348  return size_;
349 }
350 
356 template <typename CharT, typename Traits>
357 constexpr inline const CharT &
359 {
360  return data()[pos];
361 }
362 
371 template <typename CharT, typename Traits>
372 inline const CharT &
374 {
375  if (pos >= size())
376  throw std::out_of_range("Accessing a position out of bounds!");
377  return data()[pos];
378 }
379 
386 template <typename CharT, typename Traits>
387 constexpr inline const CharT &
389 {
390  return operator[](size() - 1);
391 }
392 
399 template <typename CharT, typename Traits>
400 constexpr inline const CharT &
402 {
403  return operator[](0);
404 }
405 
412 template <typename CharT, typename Traits>
413 void
415 {
416  data_ += n;
417  size_ -= n;
418 }
419 
426 template <typename CharT, typename Traits>
427 void
429 {
430  size_ -= n;
431 }
432 
438 template <typename CharT, typename Traits>
439 void
442 {
443  std::swap(data_, v.data_);
444  std::swap(size_, v.size_);
445 }
446 
447 /*
448  * Finds the first substring equal to str.
449  *
450  * @param[in] str string to search for
451  * @param[in] pos position at which to start the search
452  *
453  * @return Position of the first character of the found substring or
454  * npos if no such substring is found.
455  */
456 template <typename CharT, typename Traits>
457 typename basic_string_view<CharT, Traits>::size_type
459  size_type pos) const noexcept
460 {
461  return find(str.data(), pos, str.size());
462 }
463 
473 template <typename CharT, typename Traits>
474 typename basic_string_view<CharT, Traits>::size_type
475 basic_string_view<CharT, Traits>::find(CharT ch, size_type pos) const noexcept
476 {
477  return find(&ch, pos, 1);
478 }
479 
491 template <typename CharT, typename Traits>
492 typename basic_string_view<CharT, Traits>::size_type
493 basic_string_view<CharT, Traits>::find(const CharT *s, size_type pos,
494  size_type count) const
495 {
496  auto sz = size();
497 
498  if (pos > sz)
499  return npos;
500 
501  if (count == 0)
502  return pos;
503 
504  while (pos + count <= sz) {
505  auto found = traits_type::find(data() + pos, sz - pos, s[0]);
506  if (!found)
507  return npos;
508  pos = static_cast<size_type>(std::distance(data(), found));
509  if (traits_type::compare(found, s, count) == 0) {
510  return pos;
511  }
512  ++pos;
513  }
514  return npos;
515 }
516 
527 template <typename CharT, typename Traits>
528 typename basic_string_view<CharT, Traits>::size_type
529 basic_string_view<CharT, Traits>::find(const CharT *s, size_type pos) const
530 {
531  return find(s, pos, traits_type::length(s));
532 }
533 
544 template <typename CharT, typename Traits>
545 typename basic_string_view<CharT, Traits>::size_type
547  size_type pos) const noexcept
548 {
549  return rfind(str.data(), pos, str.size());
550 }
551 
568 template <typename CharT, typename Traits>
569 typename basic_string_view<CharT, Traits>::size_type
570 basic_string_view<CharT, Traits>::rfind(const CharT *s, size_type pos,
571  size_type count) const
572 {
573  if (count <= size()) {
574  pos = (std::min)(size() - count, pos);
575  do {
576  if (traits_type::compare(data() + pos, s, count) == 0)
577  return pos;
578  } while (pos-- > 0);
579  }
580  return npos;
581 }
582 
595 template <typename CharT, typename Traits>
596 typename basic_string_view<CharT, Traits>::size_type
597 basic_string_view<CharT, Traits>::rfind(const CharT *s, size_type pos) const
598 {
599  return rfind(s, pos, traits_type::length(s));
600 }
601 
613 template <typename CharT, typename Traits>
614 typename basic_string_view<CharT, Traits>::size_type
615 basic_string_view<CharT, Traits>::rfind(CharT ch, size_type pos) const noexcept
616 {
617  return rfind(&ch, pos, 1);
618 }
619 
629 template <typename CharT, typename Traits>
630 typename basic_string_view<CharT, Traits>::size_type
632  size_type pos) const noexcept
633 {
634  return find_first_of(str.data(), pos, str.size());
635 }
636 
650 template <typename CharT, typename Traits>
651 typename basic_string_view<CharT, Traits>::size_type
653  size_type count) const
654 {
655  size_type first_of = npos;
656  for (const CharT *c = s; c != s + count; ++c) {
657  size_type found = find(*c, pos);
658  if (found != npos && found < first_of)
659  first_of = found;
660  }
661  return first_of;
662 }
663 
676 template <typename CharT, typename Traits>
677 typename basic_string_view<CharT, Traits>::size_type
679  size_type pos) const
680 {
681  return find_first_of(s, pos, traits_type::length(s));
682 }
683 
693 template <typename CharT, typename Traits>
694 typename basic_string_view<CharT, Traits>::size_type
696  noexcept
697 {
698  return find(ch, pos);
699 }
700 
710 template <typename CharT, typename Traits>
711 typename basic_string_view<CharT, Traits>::size_type
713  size_type pos) const
714  noexcept
715 {
716  return find_first_not_of(str.data(), pos, str.size());
717 }
718 
732 template <typename CharT, typename Traits>
733 typename basic_string_view<CharT, Traits>::size_type
735  size_type pos,
736  size_type count) const
737 {
738  if (pos >= size())
739  return npos;
740 
741  for (auto it = cbegin() + pos; it != cend(); ++it)
742  if (!traits_type::find(s, count, *it))
743  return static_cast<size_type>(
744  std::distance(cbegin(), it));
745  return npos;
746 }
747 
760 template <typename CharT, typename Traits>
761 typename basic_string_view<CharT, Traits>::size_type
763  size_type pos) const
764 {
765  return find_first_not_of(s, pos, traits_type::length(s));
766 }
767 
777 template <typename CharT, typename Traits>
778 typename basic_string_view<CharT, Traits>::size_type
780  size_type pos) const
781  noexcept
782 {
783  return find_first_not_of(&ch, pos, 1);
784 }
785 
795 template <typename CharT, typename Traits>
796 typename basic_string_view<CharT, Traits>::size_type
798  size_type pos) const noexcept
799 {
800  return find_last_of(str.data(), pos, str.size());
801 }
802 
816 template <typename CharT, typename Traits>
817 typename basic_string_view<CharT, Traits>::size_type
819  size_type count) const
820 {
821  if (size() == 0 || count == 0)
822  return npos;
823 
824  bool found = false;
825  size_type last_of = 0;
826  for (const CharT *c = s; c != s + count; ++c) {
827  size_type position = rfind(*c, pos);
828  if (position != npos) {
829  found = true;
830  if (position > last_of)
831  last_of = position;
832  }
833  }
834  if (!found)
835  return npos;
836  return last_of;
837 }
838 
851 template <typename CharT, typename Traits>
852 typename basic_string_view<CharT, Traits>::size_type
854  size_type pos) const
855 {
856  return find_last_of(s, pos, traits_type::length(s));
857 }
858 
868 template <typename CharT, typename Traits>
869 typename basic_string_view<CharT, Traits>::size_type
871  noexcept
872 {
873  return rfind(ch, pos);
874 }
875 
885 template <typename CharT, typename Traits>
886 typename basic_string_view<CharT, Traits>::size_type
888  size_type pos) const noexcept
889 {
890  return find_last_not_of(str.data(), pos, str.size());
891 }
892 
906 template <typename CharT, typename Traits>
907 typename basic_string_view<CharT, Traits>::size_type
909  size_type pos,
910  size_type count) const
911 {
912  if (size() > 0) {
913  pos = (std::min)(pos, size() - 1);
914  do {
915  if (!traits_type::find(s, count, *(data() + pos)))
916  return pos;
917 
918  } while (pos-- > 0);
919  }
920  return npos;
921 }
922 
935 template <typename CharT, typename Traits>
936 typename basic_string_view<CharT, Traits>::size_type
938  size_type pos) const
939 {
940  return find_last_not_of(s, pos, traits_type::length(s));
941 }
942 
952 template <typename CharT, typename Traits>
953 typename basic_string_view<CharT, Traits>::size_type
955  size_type pos) const noexcept
956 {
957  return find_last_not_of(&ch, pos, 1);
958 }
959 
971 template <typename CharT, typename Traits>
973 basic_string_view<CharT, Traits>::substr(size_type pos, size_type count) const
974 {
975  return pos > size()
976  ? throw std::out_of_range("string_view::substr")
977  : basic_string_view(data() + pos,
978  (std::min)(count, size() - pos));
979 }
980 
993 template <typename CharT, typename Traits>
994 typename basic_string_view<CharT, Traits>::size_type
995 basic_string_view<CharT, Traits>::copy(CharT *dest, size_type count,
996  size_type pos) const
997 {
998  if (pos > size())
999  throw std::out_of_range("string_view::copy");
1000  size_type rlen = (std::min)(count, size() - pos);
1001  Traits::copy(dest, data() + pos, rlen);
1002  return rlen;
1003 }
1004 
1016 template <typename CharT, typename Traits>
1017 inline int
1018 basic_string_view<CharT, Traits>::compare(size_type pos1, size_type n1,
1019  basic_string_view sv) const
1020 {
1021  return substr(pos1, n1).compare(sv);
1022 }
1023 
1037 template <typename CharT, typename Traits>
1038 inline int
1039 basic_string_view<CharT, Traits>::compare(size_type pos1, size_type n1,
1040  basic_string_view sv, size_type pos2,
1041  size_type n2) const
1042 {
1043  return substr(pos1, n1).compare(sv.substr(pos2, n2));
1044 }
1045 
1055 template <typename CharT, typename Traits>
1056 inline int
1057 basic_string_view<CharT, Traits>::compare(const CharT *s) const noexcept
1058 {
1059  return compare(basic_string_view(s));
1060 }
1061 
1073 template <typename CharT, typename Traits>
1074 inline int
1075 basic_string_view<CharT, Traits>::compare(size_type pos1, size_type n1,
1076  const CharT *s) const
1077 {
1078  return substr(pos1, n1).compare(basic_string_view(s));
1079 }
1080 
1093 template <typename CharT, typename Traits>
1094 inline int
1095 basic_string_view<CharT, Traits>::compare(size_type pos1, size_type n1,
1096  const CharT *s, size_type n2) const
1097 {
1098  return substr(pos1, n1).compare(basic_string_view(s, n2));
1099 }
1100 
1109 template <typename CharT, typename Traits>
1110 inline int
1112  noexcept
1113 {
1114  int ret = Traits::compare(data(), other.data(),
1115  (std::min)(size(), other.size()));
1116  if (ret != 0)
1117  return ret;
1118  if (size() < other.size())
1119  return -1;
1120  if (size() > other.size())
1121  return 1;
1122  return 0;
1123 }
1124 
1128 template <class CharT, class Traits>
1129 constexpr bool
1132 {
1133  return (lhs.size() != rhs.size() ? false : lhs.compare(rhs) == 0);
1134 }
1135 
1139 template <class CharT, class Traits>
1140 constexpr bool
1143  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1144 {
1145  return (lhs.size() != rhs.size() ? false : lhs.compare(rhs) == 0);
1146 }
1147 
1151 template <class CharT, class Traits>
1152 constexpr bool
1154  typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1156 {
1157  return (lhs.size() != rhs.size() ? false : lhs.compare(rhs) == 0);
1158 }
1159 
1163 template <class CharT, class Traits>
1164 constexpr bool
1167 {
1168  return (lhs.size() != rhs.size() ? true : lhs.compare(rhs) != 0);
1169 }
1170 
1174 template <class CharT, class Traits>
1175 constexpr bool
1177  typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1179 {
1180  return (lhs.size() != rhs.size() ? true : lhs.compare(rhs) != 0);
1181 }
1182 
1186 template <class CharT, class Traits>
1187 constexpr bool
1190  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1191 {
1192  return (lhs.size() != rhs.size() ? true : lhs.compare(rhs) != 0);
1193 }
1194 
1198 template <class CharT, class Traits>
1199 constexpr bool
1202 {
1203  return lhs.compare(rhs) < 0;
1204 }
1205 
1209 template <class CharT, class Traits>
1210 constexpr bool
1211 operator<(typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1213 {
1214  return lhs.compare(rhs) < 0;
1215 }
1216 
1220 template <class CharT, class Traits>
1221 constexpr bool
1223  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1224 {
1225  return lhs.compare(rhs) < 0;
1226 }
1227 
1231 template <class CharT, class Traits>
1232 constexpr bool
1235 {
1236  return lhs.compare(rhs) <= 0;
1237 }
1238 
1242 template <class CharT, class Traits>
1243 constexpr bool
1244 operator<=(
1246  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1247 {
1248  return lhs.compare(rhs) <= 0;
1249 }
1250 
1254 template <class CharT, class Traits>
1255 constexpr bool
1256 operator<=(
1257  typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1259 {
1260  return lhs.compare(rhs) <= 0;
1261 }
1262 
1266 template <class CharT, class Traits>
1267 constexpr bool
1270 {
1271  return lhs.compare(rhs) > 0;
1272 }
1273 
1277 template <class CharT, class Traits>
1278 constexpr bool
1279 operator>(typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1281 {
1282  return lhs.compare(rhs) > 0;
1283 }
1284 
1288 template <class CharT, class Traits>
1289 constexpr bool
1291  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1292 {
1293  return lhs.compare(rhs) > 0;
1294 }
1295 
1299 template <class CharT, class Traits>
1300 constexpr bool
1303 {
1304  return lhs.compare(rhs) >= 0;
1305 }
1306 
1310 template <class CharT, class Traits>
1311 constexpr bool
1313  typename std::common_type<basic_string_view<CharT, Traits>>::type lhs,
1315 {
1316  return lhs.compare(rhs) >= 0;
1317 }
1318 
1322 template <class CharT, class Traits>
1323 constexpr bool
1326  typename std::common_type<basic_string_view<CharT, Traits>>::type rhs)
1327 {
1328  return lhs.compare(rhs) >= 0;
1329 }
1330 #endif
1331 
1332 } /* namespace obj */
1333 } /* namespace pmem */
1334 
1335 #endif /* LIBPMEMOBJ_CPP_STRING_VIEW */
pmem::obj::basic_string_view
Our partial std::string_view implementation.
Definition: string_view.hpp:46
pmem::obj::basic_string_view::copy
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:995
pmem::obj::basic_string_view::find_first_not_of
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:712
pmem::obj::basic_string_view::empty
constexpr bool empty() const noexcept
Returns that view is empty or not.
Definition: string_view.hpp:308
pmem::obj::basic_string_view::cbegin
constexpr const_iterator cbegin() const noexcept
Returns an iterator to the first character of the view.
Definition: string_view.hpp:226
pmem
Persistent memory namespace.
Definition: allocation_flag.hpp:15
pmem::obj::operator>
bool operator>(const array< T, N > &lhs, const array< T, N > &rhs)
Non-member greater than operator.
Definition: array.hpp:730
pmem::obj::basic_string_view::begin
constexpr const_iterator begin() const noexcept
Returns an iterator to the first character of the view.
Definition: string_view.hpp:214
pmem::obj::basic_string_view::rfind
size_type rfind(basic_string_view str, size_type pos=npos) const noexcept
Finds the last substring equal to str.
Definition: string_view.hpp:546
pmem::obj::basic_string_view::operator[]
constexpr const CharT & operator[](size_type pos) const noexcept
Returns reference to a character at position.
Definition: string_view.hpp:358
pmem::obj::operator>=
bool operator>=(const array< T, N > &lhs, const array< T, N > &rhs)
Non-member greater or equal operator.
Definition: array.hpp:740
pmem::obj::basic_string_view::front
constexpr const_reference front() const noexcept
Returns reference to the first character in the view.
Definition: string_view.hpp:401
pmem::obj::basic_string_view::size
constexpr size_type size() const noexcept
Returns count of characters stored in this pmem::obj::string_view data.
Definition: string_view.hpp:334
pmem::obj::operator==
bool operator==(standard_alloc_policy< T > const &, standard_alloc_policy< T2 > const &)
Determines if memory from another allocator can be deallocated from this one.
Definition: allocator.hpp:420
pmem::obj::basic_string_view::basic_string_view
constexpr basic_string_view() noexcept
Default constructor with empty data.
Definition: string_view.hpp:162
pmem::obj::basic_string_view::back
constexpr const_reference back() const noexcept
Returns reference to the last character in the view.
Definition: string_view.hpp:388
pmem::obj::basic_string_view::compare
int compare(size_type pos1, size_type n1, basic_string_view sv) const
Compares two character sequences.
Definition: string_view.hpp:1018
pmem::obj::swap
void swap(pmem::obj::array< T, N > &lhs, pmem::obj::array< T, N > &rhs)
Non-member swap function.
Definition: array.hpp:880
pmem::obj::operator!=
bool operator!=(const allocator< T, P, Tr > &lhs, const OtherAllocator &rhs)
Determines if memory from another allocator can be deallocated from this one.
Definition: allocator.hpp:536
pmem::obj::cend
pmem::obj::array< T, N >::const_iterator cend(const pmem::obj::array< T, N > &a)
Non-member cend.
Definition: array.hpp:770
pmem::obj::basic_string_view::substr
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:973
pmem::obj::basic_string_view::end
constexpr const_iterator end() const noexcept
Returns an iterator to the character following the last character of the view.
Definition: string_view.hpp:240
pmem::obj::basic_string_view::find_last_of
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:797
pmem::obj::operator<
bool operator<(const array< T, N > &lhs, const array< T, N > &rhs)
Non-member less than operator.
Definition: array.hpp:719
pmem::obj::cbegin
pmem::obj::array< T, N >::const_iterator cbegin(const pmem::obj::array< T, N > &a)
Non-member cbegin.
Definition: array.hpp:760
pmem::obj::basic_string_view::find_last_not_of
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:887
pmem::obj::operator<=
bool operator<=(const array< T, N > &lhs, const array< T, N > &rhs)
Non-member less or equal operator.
Definition: array.hpp:750
pmem::obj::basic_string_view::length
constexpr size_type length() const noexcept
Returns count of characters stored in this pmem::obj::string_view data.
Definition: string_view.hpp:346
pmem::obj::basic_string_view::remove_suffix
void remove_suffix(size_type n)
Moves the end of the view back by n characters.
Definition: string_view.hpp:428
pmem::obj::basic_string_view::find_first_of
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:631
pmem::obj::basic_string_view::data
constexpr const CharT * data() const noexcept
Returns pointer to data stored in this pmem::obj::string_view.
Definition: string_view.hpp:296
pmem::obj::basic_string_view::cend
constexpr const_iterator cend() const noexcept
Returns an iterator to the character following the last character of the view.
Definition: string_view.hpp:254
pmem::obj::basic_string_view::swap
void swap(basic_string_view &v) noexcept
Exchanges the view with that of v.
Definition: string_view.hpp:440
pmem::obj::basic_string_view::max_size
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:321
pmem::obj::basic_string_view::remove_prefix
void remove_prefix(size_type n)
Moves the start of the view forward by n characters.
Definition: string_view.hpp:414
pmem::obj::basic_string_view::at
const CharT & at(size_type pos) const
Returns reference to the character at position.
Definition: string_view.hpp:373