fidget324 created this revision. fidget324 added reviewers: hiraditya, EricWF. Herald added a subscriber: cfe-commits.
Fix an issue that was preventing std::vector from invoking the move constructor on its allocator when appropriate. Added a constructor to __vector_base which accepts an rvalue reference to the allocator, thus allowing the move constructor to be invoked. Previously, only a const lvalue reference was being accepted. This fixes bug 37694: https://bugs.llvm.org/show_bug.cgi?id=37694. Repository: rCXX libc++ https://reviews.llvm.org/D47802 Files: include/vector Index: include/vector =================================================================== --- include/vector +++ include/vector @@ -355,6 +355,7 @@ __vector_base() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a); + _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a); ~__vector_base(); _LIBCPP_INLINE_VISIBILITY @@ -438,6 +439,15 @@ { } +template <class _Tp, class _Allocator> +inline _LIBCPP_INLINE_VISIBILITY +__vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) + : __begin_(nullptr), + __end_(nullptr), + __end_cap_(nullptr, std::move(__a)) +{ +} + template <class _Tp, class _Allocator> __vector_base<_Tp, _Allocator>::~__vector_base() {
Index: include/vector =================================================================== --- include/vector +++ include/vector @@ -355,6 +355,7 @@ __vector_base() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a); + _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a); ~__vector_base(); _LIBCPP_INLINE_VISIBILITY @@ -438,6 +439,15 @@ { } +template <class _Tp, class _Allocator> +inline _LIBCPP_INLINE_VISIBILITY +__vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) + : __begin_(nullptr), + __end_(nullptr), + __end_cap_(nullptr, std::move(__a)) +{ +} + template <class _Tp, class _Allocator> __vector_base<_Tp, _Allocator>::~__vector_base() {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits