65-string-iterator-pointer.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. diff --git a/include/string b/include/string
  2. index 804373b..6465702 100644
  3. --- a/include/string
  4. +++ b/include/string
  5. @@ -753,9 +753,14 @@ public:
  6. "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
  7. "original allocator");
  8. +#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1
  9. + typedef pointer iterator;
  10. + typedef const_pointer const_iterator;
  11. +#else
  12. // TODO: Implement iterator bounds checking without requiring the global database.
  13. typedef __wrap_iter<pointer> iterator;
  14. typedef __wrap_iter<const_pointer> const_iterator;
  15. +#endif
  16. typedef std::reverse_iterator<iterator> reverse_iterator;
  17. typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
  18. @@ -1164,6 +1169,7 @@ public:
  19. #endif
  20. _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c);
  21. +#ifndef _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1
  22. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT {
  23. return __make_iterator(__get_pointer());
  24. }
  25. @@ -1176,6 +1182,20 @@ public:
  26. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT {
  27. return __make_const_iterator(__get_pointer() + size());
  28. }
  29. +#else
  30. + // It is necessary to keep the list of constructors matching the one above it.
  31. + // Made to support pointer iterators
  32. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { return iterator(__get_pointer()); }
  33. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT {
  34. + return const_iterator(__get_pointer());
  35. + }
  36. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT {
  37. + return iterator(__get_pointer() + size());
  38. + }
  39. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT {
  40. + return const_iterator(__get_pointer() + size());
  41. + }
  42. +#endif // _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1
  43. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT {
  44. return reverse_iterator(end());