diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-06-23 21:17:24 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-06-23 21:17:24 +0000 |
commit | 14e200d14d02fd36fd1ff1fd02b9b150ce170db8 (patch) | |
tree | 064e9770be840f37d5bc39b5a51a16cb0fbd3d90 /libcxx/include | |
parent | 60c16eb7f537dcabce2aa9c0f3305d7f44287cf5 (diff) | |
download | bcm5719-llvm-14e200d14d02fd36fd1ff1fd02b9b150ce170db8.tar.gz bcm5719-llvm-14e200d14d02fd36fd1ff1fd02b9b150ce170db8.zip |
Implement full support for non-pointer pointers in custom allocators for deque.
llvm-svn: 184673
Diffstat (limited to 'libcxx/include')
-rw-r--r-- | libcxx/include/__split_buffer | 12 | ||||
-rw-r--r-- | libcxx/include/deque | 35 |
2 files changed, 28 insertions, 19 deletions
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer index e0aa13b8988..f1c404f7741 100644 --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -290,7 +290,7 @@ void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) { while (__begin_ != __new_begin) - __alloc_traits::destroy(__alloc(), __begin_++); + __alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++)); } template <class _Tp, class _Allocator> @@ -307,7 +307,7 @@ void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT { while (__new_last != __end_) - __alloc_traits::destroy(__alloc(), --__end_); + __alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_)); } template <class _Tp, class _Allocator> @@ -320,7 +320,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type template <class _Tp, class _Allocator> __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a) - : __end_cap_(0, __a) + : __end_cap_(nullptr, __a) { __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr; __begin_ = __end_ = __first_ + __start; @@ -331,21 +331,21 @@ template <class _Tp, class _Allocator> _LIBCPP_INLINE_VISIBILITY inline __split_buffer<_Tp, _Allocator>::__split_buffer() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) - : __first_(0), __begin_(0), __end_(0), __end_cap_(0) + : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) { } template <class _Tp, class _Allocator> _LIBCPP_INLINE_VISIBILITY inline __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) - : __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a) + : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { } template <class _Tp, class _Allocator> _LIBCPP_INLINE_VISIBILITY inline __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) - : __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a) + : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { } diff --git a/libcxx/include/deque b/libcxx/include/deque index 8e098223d25..6c0216d7ecb 100644 --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -915,7 +915,14 @@ protected: __pointer_allocator; typedef allocator_traits<__pointer_allocator> __map_traits; typedef typename __map_traits::pointer __map_pointer; - typedef typename __map_traits::const_pointer __map_const_pointer; + typedef typename __alloc_traits::template +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + rebind_alloc<const_pointer> +#else + rebind_alloc<const_pointer>::other +#endif + __const_pointer_allocator; + typedef typename allocator_traits<__const_pointer_allocator>::const_pointer __map_const_pointer; typedef __split_buffer<pointer, __pointer_allocator> __map; typedef __deque_iterator<value_type, pointer, reference, __map_pointer, @@ -1053,7 +1060,7 @@ template <class _Tp, class _Allocator> typename __deque_base<_Tp, _Allocator>::const_iterator __deque_base<_Tp, _Allocator>::begin() const _NOEXCEPT { - __map_const_pointer __mp = __map_.begin() + __start_ / __block_size; + __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __start_ / __block_size); return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size); } @@ -1071,7 +1078,7 @@ typename __deque_base<_Tp, _Allocator>::const_iterator __deque_base<_Tp, _Allocator>::end() const _NOEXCEPT { size_type __p = size() + __start_; - __map_const_pointer __mp = __map_.begin() + __p / __block_size; + __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __block_size); return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size); } @@ -1341,6 +1348,8 @@ public: _LIBCPP_INLINE_VISIBILITY bool __invariants() const {return __base::__invariants();} private: + typedef typename __base::__map_const_pointer __map_const_pointer; + _LIBCPP_INLINE_VISIBILITY static size_type __recommend_blocks(size_type __n) { @@ -2505,9 +2514,9 @@ void deque<_Tp, _Allocator>::pop_front() { allocator_type& __a = __base::__alloc(); - __alloc_traits::destroy(__a, *(__base::__map_.begin() + - __base::__start_ / __base::__block_size) + - __base::__start_ % __base::__block_size); + __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() + + __base::__start_ / __base::__block_size) + + __base::__start_ % __base::__block_size)); --__base::size(); if (++__base::__start_ >= 2 * __base::__block_size) { @@ -2523,9 +2532,9 @@ deque<_Tp, _Allocator>::pop_back() { allocator_type& __a = __base::__alloc(); size_type __p = __base::size() + __base::__start_ - 1; - __alloc_traits::destroy(__a, *(__base::__map_.begin() + - __p / __base::__block_size) + - __p % __base::__block_size); + __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() + + __p / __base::__block_size) + + __p % __base::__block_size)); --__base::size(); if (__back_spare() >= 2 * __base::__block_size) { @@ -2556,7 +2565,7 @@ deque<_Tp, _Allocator>::__move_and_check(iterator __f, iterator __l, iterator __ __fe = __fb + __bs; } if (__fb <= __vt && __vt < __fe) - __vt = (const_iterator(__f.__m_iter_, __vt) -= __f - __r).__ptr_; + __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) -= __f - __r).__ptr_; __r = _VSTD::move(__fb, __fe, __r); __n -= __bs; __f += __bs; @@ -2587,7 +2596,7 @@ deque<_Tp, _Allocator>::__move_backward_and_check(iterator __f, iterator __l, it __lb = __le - __bs; } if (__lb <= __vt && __vt < __le) - __vt = (const_iterator(__l.__m_iter_, __vt) += __r - __l - 1).__ptr_; + __vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) += __r - __l - 1).__ptr_; __r = _VSTD::move_backward(__lb, __le, __r); __n -= __bs; __l -= __bs - 1; @@ -2618,7 +2627,7 @@ deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l, __fe = __fb + __bs; } if (__fb <= __vt && __vt < __fe) - __vt = (const_iterator(__f.__m_iter_, __vt) += __r - __f).__ptr_; + __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) += __r - __f).__ptr_; for (; __fb != __fe; ++__fb, ++__r, ++__base::size()) __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__fb)); __n -= __bs; @@ -2654,7 +2663,7 @@ deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterat __lb = __le - __bs; } if (__lb <= __vt && __vt < __le) - __vt = (const_iterator(__l.__m_iter_, __vt) -= __l - __r + 1).__ptr_; + __vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) -= __l - __r + 1).__ptr_; while (__le != __lb) { __alloc_traits::construct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__le)); |