diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-06-27 23:35:32 +0400 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-06-27 23:35:32 +0400 |
commit | 3ec1f00b733700a73adda3140e1ca2af551903d6 (patch) | |
tree | 080816321602b7bf58f0e237d15dad98f0fb6343 /libcxx/include/__bit_reference | |
parent | 161381e12076cbeb45e0c7481e68d54fe8553eb0 (diff) |
Implement full support for non-pointer pointers in custom allocators for vector.
llvm-svn: 185093
Diffstat (limited to 'libcxx/include/__bit_reference')
-rw-r--r-- | libcxx/include/__bit_reference | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference index 1621deb88834..8ff3bf6d9ee7 100644 --- a/libcxx/include/__bit_reference +++ b/libcxx/include/__bit_reference @@ -333,7 +333,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) } // do middle whole words __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(__first.__seg_, 0, __nw * sizeof(__storage_type)); + _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), 0, __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; // do last partial word if (__n > 0) @@ -363,7 +363,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) } // do middle whole words __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(__first.__seg_, -1, __nw * sizeof(__storage_type)); + _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), -1, __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; // do last partial word if (__n > 0) @@ -430,7 +430,9 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon // __first.__ctz_ == 0; // do middle words __storage_type __nw = __n / __bits_per_word; - _VSTD::memmove(__result.__seg_, __first.__seg_, __nw * sizeof(__storage_type)); + _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_), + _VSTD::__to_raw_pointer(__first.__seg_), + __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; __result.__seg_ += __nw; // do last word @@ -569,7 +571,9 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C __storage_type __nw = __n / __bits_per_word; __result.__seg_ -= __nw; __last.__seg_ -= __nw; - _VSTD::memmove(__result.__seg_, __last.__seg_, __nw * sizeof(__storage_type)); + _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_), + _VSTD::__to_raw_pointer(__last.__seg_), + __nw * sizeof(__storage_type)); __n -= __nw * __bits_per_word; // do last word if (__n > 0) @@ -870,6 +874,7 @@ struct __bit_array { typedef typename _Cp::difference_type difference_type; typedef typename _Cp::__storage_type __storage_type; + typedef typename _Cp::__storage_pointer __storage_pointer; typedef typename _Cp::iterator iterator; static const unsigned __bits_per_word = _Cp::__bits_per_word; static const unsigned _Np = 4; @@ -880,9 +885,15 @@ struct __bit_array _LIBCPP_INLINE_VISIBILITY static difference_type capacity() {return static_cast<difference_type>(_Np * __bits_per_word);} _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {} - _LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(__word_, 0);} - _LIBCPP_INLINE_VISIBILITY iterator end() {return iterator(__word_ + __size_ / __bits_per_word, - static_cast<unsigned>(__size_ % __bits_per_word));} + _LIBCPP_INLINE_VISIBILITY iterator begin() + { + return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0); + } + _LIBCPP_INLINE_VISIBILITY iterator end() + { + return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word, + static_cast<unsigned>(__size_ % __bits_per_word)); + } }; template <class _Cp> |