diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -812,6 +812,14 @@ std::__debug_db_insert_c(this); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) { + return iterator(this, __p); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_const_iterator(const_pointer __p) { + return const_iterator(this, __p); + } + public: _LIBCPP_TEMPLATE_DATA_VIS static const size_type npos = -1; @@ -1028,16 +1036,16 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT - {return iterator(this, __get_pointer());} + {return __make_iterator(__get_pointer());} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT - {return const_iterator(this, __get_pointer());} + {return __make_const_iterator(__get_pointer());} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT - {return iterator(this, __get_pointer() + size());} + {return __make_iterator(__get_pointer() + size());} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT - {return const_iterator(this, __get_pointer() + size());} + {return __make_const_iterator(__get_pointer() + size());} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -685,9 +685,9 @@ _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; + iterator __make_iter(pointer __p) _NOEXCEPT { return iterator(this, __p); } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI - const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; + const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { return const_iterator(this, __p); } _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 __swap_out_circular_buffer(__split_buffer& __v, pointer __p); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_range(pointer __from_s, pointer __from_e, pointer __to); @@ -1376,7 +1376,7 @@ typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::begin() _NOEXCEPT { - return iterator(this, this->__begin_); + return __make_iter(this->__begin_); } template @@ -1385,7 +1385,7 @@ typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::begin() const _NOEXCEPT { - return const_iterator(this, this->__begin_); + return __make_iter(this->__begin_); } template @@ -1394,7 +1394,7 @@ typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::end() _NOEXCEPT { - return iterator(this, this->__end_); + return __make_iter(this->__end_); } template @@ -1403,7 +1403,7 @@ typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::end() const _NOEXCEPT { - return const_iterator(this, this->__end_); + return __make_iter(this->__end_); } template @@ -1587,8 +1587,7 @@ this->__destruct_at_end(std::move(__p + 1, this->__end_, __p)); if (!__libcpp_is_constant_evaluated()) this->__invalidate_iterators_past(__p - 1); - iterator __r = iterator(this, __p); - return __r; + return __make_iter(__p); } template @@ -1608,8 +1607,7 @@ if (!__libcpp_is_constant_evaluated()) this->__invalidate_iterators_past(__p - 1); } - iterator __r = iterator(this, __p); - return __r; + return __make_iter(__p); } template @@ -1663,7 +1661,7 @@ __v.push_back(__x); __p = __swap_out_circular_buffer(__v, __p); } - return iterator(this, __p); + return __make_iter(__p); } template @@ -1693,7 +1691,7 @@ __v.push_back(std::move(__x)); __p = __swap_out_circular_buffer(__v, __p); } - return iterator(this, __p); + return __make_iter(__p); } template @@ -1725,7 +1723,7 @@ __v.emplace_back(std::forward<_Args>(__args)...); __p = __swap_out_circular_buffer(__v, __p); } - return iterator(this, __p); + return __make_iter(__p); } template @@ -1766,7 +1764,7 @@ __p = __swap_out_circular_buffer(__v, __p); } } - return iterator(this, __p); + return __make_iter(__p); } template @@ -1803,14 +1801,14 @@ } catch (...) { - erase(iterator(this, __old_last), end()); + erase(__make_iter(__old_last), end()); throw; } #endif // _LIBCPP_NO_EXCEPTIONS } __p = std::rotate(__p, __old_last, this->__end_); - insert(iterator(this, __p), std::make_move_iterator(__v.begin()), - std::make_move_iterator(__v.end())); + insert(__make_iter(__p), std::make_move_iterator(__v.begin()), + std::make_move_iterator(__v.end())); return begin() + __off; } @@ -1855,7 +1853,7 @@ __p = __swap_out_circular_buffer(__v, __p); } } - return iterator(this, __p); + return __make_iter(__p); } template