66-vector-iterator-pointer.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. diff --git a/include/vector b/include/vector
  2. index 559b7fd..659b035 100644
  3. --- a/include/vector
  4. +++ b/include/vector
  5. @@ -396,9 +396,14 @@ public:
  6. typedef typename __alloc_traits::difference_type difference_type;
  7. typedef typename __alloc_traits::pointer pointer;
  8. typedef typename __alloc_traits::const_pointer const_pointer;
  9. +#if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 1
  10. + typedef pointer iterator;
  11. + typedef const_pointer const_iterator;
  12. +#else
  13. // TODO: Implement iterator bounds checking without requiring the global database.
  14. typedef __wrap_iter<pointer> iterator;
  15. typedef __wrap_iter<const_pointer> const_iterator;
  16. +#endif
  17. typedef std::reverse_iterator<iterator> reverse_iterator;
  18. typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
  19. @@ -823,9 +828,9 @@ private:
  20. _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);
  21. _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x);
  22. _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
  23. - iterator __make_iter(pointer __p) _NOEXCEPT { return iterator(__p); }
  24. + iterator __make_iter(pointer __p) _NOEXCEPT;
  25. _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
  26. - const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { return const_iterator(__p); }
  27. + const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;
  28. _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
  29. _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
  30. _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_range(pointer __from_s, pointer __from_e, pointer __to);
  31. @@ -1497,6 +1502,34 @@ void vector<_Tp, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sent
  32. }
  33. }
  34. +// We need to save the make_iter function and replace all constructor calls with it
  35. +// Made to support pointer iterators
  36. +template <class _Tp, class _Allocator>
  37. +_LIBCPP_CONSTEXPR_SINCE_CXX20
  38. +inline _LIBCPP_INLINE_VISIBILITY
  39. +typename vector<_Tp, _Allocator>::iterator
  40. +vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT
  41. +{
  42. +#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1
  43. + return iterator(__p);
  44. +#else
  45. + return iterator(this, __p);
  46. +#endif
  47. +}
  48. +
  49. +template <class _Tp, class _Allocator>
  50. +_LIBCPP_CONSTEXPR_SINCE_CXX20
  51. +inline _LIBCPP_INLINE_VISIBILITY
  52. +typename vector<_Tp, _Allocator>::const_iterator
  53. +vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT
  54. +{
  55. +#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1
  56. + return const_iterator(__p);
  57. +#else
  58. + return const_iterator(this, __p);
  59. +#endif
  60. +}
  61. +
  62. template <class _Tp, class _Allocator>
  63. _LIBCPP_CONSTEXPR_SINCE_CXX20
  64. void