Implement full support for non-pointer pointers in custom allocators for vector.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@185093 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2013-06-27 19:35:32 +00:00
parent 29f7432ff3
commit 2c39cbe020
98 changed files with 1721 additions and 91 deletions

View File

@@ -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>