diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -813,6 +813,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 const_iterator __make_const_iterator(const_pointer __p) const { + return const_iterator(this, __p); + } + public: _LIBCPP_TEMPLATE_DATA_VIS static const size_type npos = -1; @@ -1029,16 +1037,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 @@ -686,9 +686,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); @@ -1377,7 +1377,7 @@ typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::begin() _NOEXCEPT { - return iterator(this, this->__begin_); + return __make_iter(this->__begin_); } template @@ -1386,7 +1386,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 @@ -1395,7 +1395,7 @@ typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::end() _NOEXCEPT { - return iterator(this, this->__end_); + return __make_iter(this->__end_); } template @@ -1404,7 +1404,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 @@ -1588,8 +1588,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 @@ -1609,8 +1608,7 @@ if (!__libcpp_is_constant_evaluated()) this->__invalidate_iterators_past(__p - 1); } - iterator __r = iterator(this, __p); - return __r; + return __make_iter(__p); } template @@ -1664,7 +1662,7 @@ __v.push_back(__x); __p = __swap_out_circular_buffer(__v, __p); } - return iterator(this, __p); + return __make_iter(__p); } template @@ -1694,7 +1692,7 @@ __v.push_back(std::move(__x)); __p = __swap_out_circular_buffer(__v, __p); } - return iterator(this, __p); + return __make_iter(__p); } template @@ -1726,7 +1724,7 @@ __v.emplace_back(std::forward<_Args>(__args)...); __p = __swap_out_circular_buffer(__v, __p); } - return iterator(this, __p); + return __make_iter(__p); } template @@ -1767,7 +1765,7 @@ __p = __swap_out_circular_buffer(__v, __p); } } - return iterator(this, __p); + return __make_iter(__p); } template @@ -1804,14 +1802,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; } @@ -1856,7 +1854,7 @@ __p = __swap_out_circular_buffer(__v, __p); } } - return iterator(this, __p); + return __make_iter(__p); } template