diff --git a/include/vector b/include/vector index 8d5b846..b989a3c 100644 --- a/include/vector +++ b/include/vector @@ -401,9 +401,14 @@ public: typedef typename __alloc_traits::difference_type difference_type; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; +#if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 1 + typedef pointer iterator; + typedef const_pointer const_iterator; +#else // TODO: Implement iterator bounds checking without requiring the global database. typedef __wrap_iter iterator; typedef __wrap_iter const_iterator; +#endif typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; @@ -807,12 +812,8 @@ private: void __append_uninitialized(size_type __n); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x); - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT { - return iterator(__p); - } - _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { - return const_iterator(__p); - } + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT; + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_out_circular_buffer(__split_buffer& __v); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer @@ -1389,6 +1390,28 @@ vector<_Tp, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sentinel } } +// We need to save the make_iter function and replace all constructor calls with it +// Made to support pointer iterators +template +_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator +vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT { +#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1 + return iterator(__p); +#else + return iterator(this, __p); +#endif +} + +template +_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_iterator +vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT { +#if _YNDX_LIBCPP_MAKE_STRING_ITERATOR_POINTERS == 1 + return const_iterator(__p); +#else + return const_iterator(this, __p); +#endif +} + template _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) { if (__n <= capacity()) {