Index: include/deque =================================================================== --- include/deque +++ include/deque @@ -170,100 +170,105 @@ template class __deque_base; template > class _LIBCPP_TYPE_VIS_ONLY deque; +template +struct __calculate_block_size { + static const difference_type __block_size = sizeof(value_type) < 256 ? 4096 / sizeof(value_type) : 16; +}; + template + class _DiffType> class _LIBCPP_TYPE_VIS_ONLY __deque_iterator; template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> +__deque_iterator<_V2, _P2, _R2, _M2, _D2> copy(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0); template _OutputIterator -copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, +copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r); template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> -copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); +__deque_iterator<_V2, _P2, _R2, _M2, _D2> +copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r); template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> +__deque_iterator<_V2, _P2, _R2, _M2, _D2> copy_backward(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0); template _OutputIterator -copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, +copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r); template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> -copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); +__deque_iterator<_V2, _P2, _R2, _M2, _D2> +copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r); template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> +__deque_iterator<_V2, _P2, _R2, _M2, _D2> move(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0); template _OutputIterator -move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, +move(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r); template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> -move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); +__deque_iterator<_V2, _P2, _R2, _M2, _D2> +move(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r); template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> +__deque_iterator<_V2, _P2, _R2, _M2, _D2> move_backward(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0); template _OutputIterator -move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, +move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r); template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> -move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); +__deque_iterator<_V2, _P2, _R2, _M2, _D2> +move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r); template + class _DiffType> class _LIBCPP_TYPE_VIS_ONLY __deque_iterator { typedef _MapPointer __map_iterator; @@ -273,8 +278,7 @@ private: __map_iterator __m_iter_; pointer __ptr_; - - static const difference_type __block_size = _BlockSize; + typedef __calculate_block_size<_ValueType, difference_type> __value_traits; public: typedef _ValueType value_type; typedef random_access_iterator_tag iterator_category; @@ -288,7 +292,7 @@ template _LIBCPP_INLINE_VISIBILITY - __deque_iterator(const __deque_iterator& __it, + __deque_iterator(const __deque_iterator& __it, typename enable_if::value>::type* = 0) _NOEXCEPT : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {} @@ -297,7 +301,7 @@ _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator++() { - if (++__ptr_ - *__m_iter_ == __block_size) + if (++__ptr_ - *__m_iter_ == __value_traits::__block_size) { ++__m_iter_; __ptr_ = *__m_iter_; @@ -317,7 +321,7 @@ if (__ptr_ == *__m_iter_) { --__m_iter_; - __ptr_ = *__m_iter_ + __block_size; + __ptr_ = *__m_iter_ + __value_traits::__block_size; } --__ptr_; return *this; @@ -337,14 +341,14 @@ __n += __ptr_ - *__m_iter_; if (__n > 0) { - __m_iter_ += __n / __block_size; - __ptr_ = *__m_iter_ + __n % __block_size; + __m_iter_ += __n / __value_traits::__block_size; + __ptr_ = *__m_iter_ + __n % __value_traits::__block_size; } else // (__n < 0) { - difference_type __z = __block_size - 1 - __n; - __m_iter_ -= __z / __block_size; - __ptr_ = *__m_iter_ + (__block_size - 1 - __z % __block_size); + difference_type __z = __value_traits::__block_size - 1 - __n; + __m_iter_ -= __z / __value_traits::__block_size; + __ptr_ = *__m_iter_ + (__value_traits::__block_size - 1 - __z % __value_traits::__block_size); } } return *this; @@ -377,7 +381,7 @@ friend difference_type operator-(const __deque_iterator& __x, const __deque_iterator& __y) { if (__x != __y) - return (__x.__m_iter_ - __y.__m_iter_) * __block_size + return (__x.__m_iter_ - __y.__m_iter_) * __value_traits::__block_size + (__x.__ptr_ - *__x.__m_iter_) - (__y.__ptr_ - *__y.__m_iter_); return 0; @@ -417,122 +421,122 @@ template friend class __deque_base; template friend class _LIBCPP_TYPE_VIS_ONLY deque; - template + template friend class _LIBCPP_TYPE_VIS_ONLY __deque_iterator; template friend - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> + __deque_iterator<_V2, _P2, _R2, _M2, _D2> copy(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*); template friend _OutputIterator - copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, + copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r); template friend - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> - copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); + __deque_iterator<_V2, _P2, _R2, _M2, _D2> + copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r); template friend - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> + __deque_iterator<_V2, _P2, _R2, _M2, _D2> copy_backward(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*); template friend _OutputIterator - copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, + copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r); template friend - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> - copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); + __deque_iterator<_V2, _P2, _R2, _M2, _D2> + copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r); template friend - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> + __deque_iterator<_V2, _P2, _R2, _M2, _D2> move(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*); template friend _OutputIterator - move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, + move(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r); template friend - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> - move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); + __deque_iterator<_V2, _P2, _R2, _M2, _D2> + move(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r); template friend - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> + __deque_iterator<_V2, _P2, _R2, _M2, _D2> move_backward(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*); template friend _OutputIterator - move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, + move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r); template friend - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> - move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); + __deque_iterator<_V2, _P2, _R2, _M2, _D2> + move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r); }; // copy template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> +__deque_iterator<_V2, _P2, _R2, _M2, _D2> copy(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*) { - typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type; - typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer; + typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2>::difference_type difference_type; + typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2>::pointer pointer; while (__f != __l) { pointer __rb = __r.__ptr_; @@ -555,12 +559,12 @@ template _OutputIterator -copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, +copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r) { - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::difference_type difference_type; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::pointer pointer; difference_type __n = __l - __f; while (__n > 0) { @@ -581,13 +585,13 @@ template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> -copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r) +__deque_iterator<_V2, _P2, _R2, _M2, _D2> +copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r) { - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::difference_type difference_type; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::pointer pointer; difference_type __n = __l - __f; while (__n > 0) { @@ -610,17 +614,17 @@ template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> +__deque_iterator<_V2, _P2, _R2, _M2, _D2> copy_backward(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*) { - typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type; - typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer; + typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2>::difference_type difference_type; + typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2>::pointer pointer; while (__f != __l) { - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __rp = _VSTD::prev(__r); + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __rp = _VSTD::prev(__r); pointer __rb = *__rp.__m_iter_; pointer __re = __rp.__ptr_ + 1; difference_type __bs = __re - __rb; @@ -641,12 +645,12 @@ template _OutputIterator -copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, +copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r) { - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::difference_type difference_type; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::pointer pointer; difference_type __n = __l - __f; while (__n > 0) { @@ -668,13 +672,13 @@ template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> -copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r) +__deque_iterator<_V2, _P2, _R2, _M2, _D2> +copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r) { - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::difference_type difference_type; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::pointer pointer; difference_type __n = __l - __f; while (__n > 0) { @@ -698,14 +702,14 @@ template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> +__deque_iterator<_V2, _P2, _R2, _M2, _D2> move(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*) { - typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type; - typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer; + typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2>::difference_type difference_type; + typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2>::pointer pointer; while (__f != __l) { pointer __rb = __r.__ptr_; @@ -728,12 +732,12 @@ template _OutputIterator -move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, +move(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r) { - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::difference_type difference_type; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::pointer pointer; difference_type __n = __l - __f; while (__n > 0) { @@ -754,13 +758,13 @@ template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> -move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r) +__deque_iterator<_V2, _P2, _R2, _M2, _D2> +move(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r) { - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::difference_type difference_type; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::pointer pointer; difference_type __n = __l - __f; while (__n > 0) { @@ -783,17 +787,17 @@ template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> +__deque_iterator<_V2, _P2, _R2, _M2, _D2> move_backward(_RAIter __f, _RAIter __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r, typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*) { - typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type; - typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer; + typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2>::difference_type difference_type; + typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2>::pointer pointer; while (__f != __l) { - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __rp = _VSTD::prev(__r); + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __rp = _VSTD::prev(__r); pointer __rb = *__rp.__m_iter_; pointer __re = __rp.__ptr_ + 1; difference_type __bs = __re - __rb; @@ -814,12 +818,12 @@ template _OutputIterator -move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, +move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, _OutputIterator __r) { - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::difference_type difference_type; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::pointer pointer; difference_type __n = __l - __f; while (__n > 0) { @@ -841,13 +845,13 @@ template -__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> -move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, - __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, - __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r) +__deque_iterator<_V2, _P2, _R2, _M2, _D2> +move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1> __f, + __deque_iterator<_V1, _P1, _R1, _M1, _D1> __l, + __deque_iterator<_V2, _P2, _R2, _M2, _D2> __r) { - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; - typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::difference_type difference_type; + typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1>::pointer pointer; difference_type __n = __l - __f; while (__n > 0) { @@ -909,8 +913,7 @@ typedef typename __alloc_traits::difference_type difference_type; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; - - static const difference_type __block_size = sizeof(value_type) < 256 ? 4096 / sizeof(value_type) : 16; + typedef __calculate_block_size __value_traits; typedef typename __rebind_alloc_helper<__alloc_traits, pointer>::type __pointer_allocator; typedef allocator_traits<__pointer_allocator> __map_traits; @@ -920,9 +923,9 @@ typedef __split_buffer __map; typedef __deque_iterator iterator; + difference_type> iterator; typedef __deque_iterator const_iterator; + difference_type> const_iterator; __map __map_; size_type __start_; @@ -1019,7 +1022,7 @@ { if (!__map_.__invariants()) return false; - if (__map_.size() >= size_type(-1) / __block_size) + if (__map_.size() >= size_type(-1) / __value_traits::__block_size) return false; for (typename __map::const_iterator __i = __map_.begin(), __e = __map_.end(); __i != __e; ++__i) @@ -1027,9 +1030,9 @@ return false; if (__map_.size() != 0) { - if (size() >= __map_.size() * __block_size) + if (size() >= __map_.size() * __value_traits::__block_size) return false; - if (__start_ >= __map_.size() * __block_size - size()) + if (__start_ >= __map_.size() * __value_traits::__block_size - size()) return false; } else @@ -1046,16 +1049,16 @@ typename __deque_base<_Tp, _Allocator>::iterator __deque_base<_Tp, _Allocator>::begin() _NOEXCEPT { - __map_pointer __mp = __map_.begin() + __start_ / __block_size; - return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size); + __map_pointer __mp = __map_.begin() + __start_ / __value_traits::__block_size; + return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __value_traits::__block_size); } template typename __deque_base<_Tp, _Allocator>::const_iterator __deque_base<_Tp, _Allocator>::begin() const _NOEXCEPT { - __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); + __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __start_ / __value_traits::__block_size); + return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __value_traits::__block_size); } template @@ -1063,8 +1066,8 @@ __deque_base<_Tp, _Allocator>::end() _NOEXCEPT { size_type __p = size() + __start_; - __map_pointer __mp = __map_.begin() + __p / __block_size; - return iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size); + __map_pointer __mp = __map_.begin() + __p / __value_traits::__block_size; + return iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __value_traits::__block_size); } template @@ -1072,8 +1075,8 @@ __deque_base<_Tp, _Allocator>::end() const _NOEXCEPT { size_type __p = size() + __start_; - __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); + __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __value_traits::__block_size); + return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __value_traits::__block_size); } template @@ -1094,7 +1097,7 @@ typename __map::iterator __i = __map_.begin(); typename __map::iterator __e = __map_.end(); for (; __i != __e; ++__i) - __alloc_traits::deallocate(__alloc(), *__i, __block_size); + __alloc_traits::deallocate(__alloc(), *__i, __value_traits::__block_size); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1153,16 +1156,16 @@ size() = 0; while (__map_.size() > 2) { - __alloc_traits::deallocate(__a, __map_.front(), __block_size); + __alloc_traits::deallocate(__a, __map_.front(), __value_traits::__block_size); __map_.pop_front(); } switch (__map_.size()) { case 1: - __start_ = __block_size / 2; + __start_ = __value_traits::__block_size / 2; break; case 2: - __start_ = __block_size; + __start_ = __value_traits::__block_size; break; } } @@ -1192,6 +1195,10 @@ typedef _VSTD::reverse_iterator reverse_iterator; typedef _VSTD::reverse_iterator const_reverse_iterator; +private: + typedef __calculate_block_size __value_traits; +public: + // construct/copy/destroy: _LIBCPP_INLINE_VISIBILITY deque() @@ -1354,12 +1361,12 @@ _LIBCPP_INLINE_VISIBILITY static size_type __recommend_blocks(size_type __n) { - return __n / __base::__block_size + (__n % __base::__block_size != 0); + return __n / __value_traits::__block_size + (__n % __value_traits::__block_size != 0); } _LIBCPP_INLINE_VISIBILITY size_type __capacity() const { - return __base::__map_.size() == 0 ? 0 : __base::__map_.size() * __base::__block_size - 1; + return __base::__map_.size() == 0 ? 0 : __base::__map_.size() * __value_traits::__block_size - 1; } _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const @@ -1656,22 +1663,22 @@ { while (__base::__map_.size() > 0) { - __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size); + __alloc_traits::deallocate(__a, __base::__map_.back(), __value_traits::__block_size); __base::__map_.pop_back(); } __base::__start_ = 0; } else { - if (__front_spare() >= __base::__block_size) + if (__front_spare() >= __value_traits::__block_size) { - __alloc_traits::deallocate(__a, __base::__map_.front(), __base::__block_size); + __alloc_traits::deallocate(__a, __base::__map_.front(), __value_traits::__block_size); __base::__map_.pop_front(); - __base::__start_ -= __base::__block_size; + __base::__start_ -= __value_traits::__block_size; } - if (__back_spare() >= __base::__block_size) + if (__back_spare() >= __value_traits::__block_size) { - __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size); + __alloc_traits::deallocate(__a, __base::__map_.back(), __value_traits::__block_size); __base::__map_.pop_back(); } } @@ -1684,7 +1691,7 @@ deque<_Tp, _Allocator>::operator[](size_type __i) { size_type __p = __base::__start_ + __i; - return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size); + return *(*(__base::__map_.begin() + __p / __value_traits::__block_size) + __p % __value_traits::__block_size); } template @@ -1693,7 +1700,7 @@ deque<_Tp, _Allocator>::operator[](size_type __i) const { size_type __p = __base::__start_ + __i; - return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size); + return *(*(__base::__map_.begin() + __p / __value_traits::__block_size) + __p % __value_traits::__block_size); } template @@ -1704,7 +1711,7 @@ if (__i >= __base::size()) __base::__throw_out_of_range(); size_type __p = __base::__start_ + __i; - return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size); + return *(*(__base::__map_.begin() + __p / __value_traits::__block_size) + __p % __value_traits::__block_size); } template @@ -1715,7 +1722,7 @@ if (__i >= __base::size()) __base::__throw_out_of_range(); size_type __p = __base::__start_ + __i; - return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size); + return *(*(__base::__map_.begin() + __p / __value_traits::__block_size) + __p % __value_traits::__block_size); } template @@ -1723,8 +1730,8 @@ typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::front() { - return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size) - + __base::__start_ % __base::__block_size); + return *(*(__base::__map_.begin() + __base::__start_ / __value_traits::__block_size) + + __base::__start_ % __value_traits::__block_size); } template @@ -1732,8 +1739,8 @@ typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::front() const { - return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size) - + __base::__start_ % __base::__block_size); + return *(*(__base::__map_.begin() + __base::__start_ / __value_traits::__block_size) + + __base::__start_ % __value_traits::__block_size); } template @@ -1742,7 +1749,7 @@ deque<_Tp, _Allocator>::back() { size_type __p = __base::size() + __base::__start_ - 1; - return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size); + return *(*(__base::__map_.begin() + __p / __value_traits::__block_size) + __p % __value_traits::__block_size); } template @@ -1751,7 +1758,7 @@ deque<_Tp, _Allocator>::back() const { size_type __p = __base::size() + __base::__start_ - 1; - return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size); + return *(*(__base::__map_.begin() + __p / __value_traits::__block_size) + __p % __value_traits::__block_size); } template @@ -2244,9 +2251,9 @@ deque<_Tp, _Allocator>::__add_front_capacity() { allocator_type& __a = __base::__alloc(); - if (__back_spare() >= __base::__block_size) + if (__back_spare() >= __value_traits::__block_size) { - __base::__start_ += __base::__block_size; + __base::__start_ += __value_traits::__block_size; pointer __pt = __base::__map_.back(); __base::__map_.pop_back(); __base::__map_.push_front(__pt); @@ -2257,18 +2264,18 @@ // until all buffers are allocated. If we throw, we don't need to fix // anything up (any added buffers are undetectible) if (__base::__map_.__front_spare() > 0) - __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size)); + __base::__map_.push_front(__alloc_traits::allocate(__a, __value_traits::__block_size)); else { - __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size)); + __base::__map_.push_back(__alloc_traits::allocate(__a, __value_traits::__block_size)); // Done allocating, reorder capacity pointer __pt = __base::__map_.back(); __base::__map_.pop_back(); __base::__map_.push_front(__pt); } __base::__start_ = __base::__map_.size() == 1 ? - __base::__block_size / 2 : - __base::__start_ + __base::__block_size; + __value_traits::__block_size / 2 : + __base::__start_ + __value_traits::__block_size; } // Else need to allocate 1 buffer, *and* we need to reallocate __map_. else @@ -2279,8 +2286,8 @@ typedef __allocator_destructor<_Allocator> _Dp; unique_ptr __hold( - __alloc_traits::allocate(__a, __base::__block_size), - _Dp(__a, __base::__block_size)); + __alloc_traits::allocate(__a, __value_traits::__block_size), + _Dp(__a, __value_traits::__block_size)); __buf.push_back(__hold.get()); __hold.release(); @@ -2292,8 +2299,8 @@ _VSTD::swap(__base::__map_.__end_, __buf.__end_); _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap()); __base::__start_ = __base::__map_.size() == 1 ? - __base::__block_size / 2 : - __base::__start_ + __base::__block_size; + __value_traits::__block_size / 2 : + __base::__start_ + __value_traits::__block_size; } } @@ -2306,13 +2313,13 @@ allocator_type& __a = __base::__alloc(); size_type __nb = __recommend_blocks(__n + __base::__map_.empty()); // Number of unused blocks at back: - size_type __back_capacity = __back_spare() / __base::__block_size; + size_type __back_capacity = __back_spare() / __value_traits::__block_size; __back_capacity = _VSTD::min(__back_capacity, __nb); // don't take more than you need __nb -= __back_capacity; // number of blocks need to allocate // If __nb == 0, then we have sufficient capacity. if (__nb == 0) { - __base::__start_ += __base::__block_size * __back_capacity; + __base::__start_ += __value_traits::__block_size * __back_capacity; for (; __back_capacity > 0; --__back_capacity) { pointer __pt = __base::__map_.back(); @@ -2325,16 +2332,16 @@ { // we can put the new buffers into the map, but don't shift things around // until all buffers are allocated. If we throw, we don't need to fix // anything up (any added buffers are undetectible) - for (; __nb > 0; --__nb, __base::__start_ += __base::__block_size - (__base::__map_.size() == 1)) + for (; __nb > 0; --__nb, __base::__start_ += __value_traits::__block_size - (__base::__map_.size() == 1)) { if (__base::__map_.__front_spare() == 0) break; - __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size)); + __base::__map_.push_front(__alloc_traits::allocate(__a, __value_traits::__block_size)); } for (; __nb > 0; --__nb, ++__back_capacity) - __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size)); + __base::__map_.push_back(__alloc_traits::allocate(__a, __value_traits::__block_size)); // Done allocating, reorder capacity - __base::__start_ += __back_capacity * __base::__block_size; + __base::__start_ += __back_capacity * __value_traits::__block_size; for (; __back_capacity > 0; --__back_capacity) { pointer __pt = __base::__map_.back(); @@ -2345,7 +2352,7 @@ // Else need to allocate __nb buffers, *and* we need to reallocate __map_. else { - size_type __ds = (__nb + __back_capacity) * __base::__block_size - __base::__map_.empty(); + size_type __ds = (__nb + __back_capacity) * __value_traits::__block_size - __base::__map_.empty(); __split_buffer __buf(max(2* __base::__map_.capacity(), __nb + __base::__map_.size()), @@ -2355,14 +2362,14 @@ { #endif // _LIBCPP_NO_EXCEPTIONS for (; __nb > 0; --__nb) - __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size)); + __buf.push_back(__alloc_traits::allocate(__a, __value_traits::__block_size)); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { for (typename __base::__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) - __alloc_traits::deallocate(__a, *__i, __base::__block_size); + __alloc_traits::deallocate(__a, *__i, __value_traits::__block_size); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2389,9 +2396,9 @@ deque<_Tp, _Allocator>::__add_back_capacity() { allocator_type& __a = __base::__alloc(); - if (__front_spare() >= __base::__block_size) + if (__front_spare() >= __value_traits::__block_size) { - __base::__start_ -= __base::__block_size; + __base::__start_ -= __value_traits::__block_size; pointer __pt = __base::__map_.front(); __base::__map_.pop_front(); __base::__map_.push_back(__pt); @@ -2402,10 +2409,10 @@ // until it is allocated. If we throw, we don't need to fix // anything up (any added buffers are undetectible) if (__base::__map_.__back_spare() != 0) - __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size)); + __base::__map_.push_back(__alloc_traits::allocate(__a, __value_traits::__block_size)); else { - __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size)); + __base::__map_.push_front(__alloc_traits::allocate(__a, __value_traits::__block_size)); // Done allocating, reorder capacity pointer __pt = __base::__map_.front(); __base::__map_.pop_front(); @@ -2422,8 +2429,8 @@ typedef __allocator_destructor<_Allocator> _Dp; unique_ptr __hold( - __alloc_traits::allocate(__a, __base::__block_size), - _Dp(__a, __base::__block_size)); + __alloc_traits::allocate(__a, __value_traits::__block_size), + _Dp(__a, __value_traits::__block_size)); __buf.push_back(__hold.get()); __hold.release(); @@ -2446,13 +2453,13 @@ allocator_type& __a = __base::__alloc(); size_type __nb = __recommend_blocks(__n + __base::__map_.empty()); // Number of unused blocks at front: - size_type __front_capacity = __front_spare() / __base::__block_size; + size_type __front_capacity = __front_spare() / __value_traits::__block_size; __front_capacity = _VSTD::min(__front_capacity, __nb); // don't take more than you need __nb -= __front_capacity; // number of blocks need to allocate // If __nb == 0, then we have sufficient capacity. if (__nb == 0) { - __base::__start_ -= __base::__block_size * __front_capacity; + __base::__start_ -= __value_traits::__block_size * __front_capacity; for (; __front_capacity > 0; --__front_capacity) { pointer __pt = __base::__map_.front(); @@ -2469,13 +2476,13 @@ { if (__base::__map_.__back_spare() == 0) break; - __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size)); + __base::__map_.push_back(__alloc_traits::allocate(__a, __value_traits::__block_size)); } for (; __nb > 0; --__nb, ++__front_capacity, __base::__start_ += - __base::__block_size - (__base::__map_.size() == 1)) - __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size)); + __value_traits::__block_size - (__base::__map_.size() == 1)) + __base::__map_.push_front(__alloc_traits::allocate(__a, __value_traits::__block_size)); // Done allocating, reorder capacity - __base::__start_ -= __base::__block_size * __front_capacity; + __base::__start_ -= __value_traits::__block_size * __front_capacity; for (; __front_capacity > 0; --__front_capacity) { pointer __pt = __base::__map_.front(); @@ -2486,7 +2493,7 @@ // Else need to allocate __nb buffers, *and* we need to reallocate __map_. else { - size_type __ds = __front_capacity * __base::__block_size; + size_type __ds = __front_capacity * __value_traits::__block_size; __split_buffer __buf(max(2* __base::__map_.capacity(), __nb + __base::__map_.size()), @@ -2497,14 +2504,14 @@ { #endif // _LIBCPP_NO_EXCEPTIONS for (; __nb > 0; --__nb) - __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size)); + __buf.push_back(__alloc_traits::allocate(__a, __value_traits::__block_size)); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { for (typename __base::__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) - __alloc_traits::deallocate(__a, *__i, __base::__block_size); + __alloc_traits::deallocate(__a, *__i, __value_traits::__block_size); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2530,14 +2537,14 @@ { allocator_type& __a = __base::__alloc(); __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() + - __base::__start_ / __base::__block_size) + - __base::__start_ % __base::__block_size)); + __base::__start_ / __value_traits::__block_size) + + __base::__start_ % __value_traits::__block_size)); --__base::size(); - if (++__base::__start_ >= 2 * __base::__block_size) + if (++__base::__start_ >= 2 * __value_traits::__block_size) { - __alloc_traits::deallocate(__a, __base::__map_.front(), __base::__block_size); + __alloc_traits::deallocate(__a, __base::__map_.front(), __value_traits::__block_size); __base::__map_.pop_front(); - __base::__start_ -= __base::__block_size; + __base::__start_ -= __value_traits::__block_size; } } @@ -2548,12 +2555,12 @@ allocator_type& __a = __base::__alloc(); size_type __p = __base::size() + __base::__start_ - 1; __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() + - __p / __base::__block_size) + - __p % __base::__block_size)); + __p / __value_traits::__block_size) + + __p % __value_traits::__block_size)); --__base::size(); - if (__back_spare() >= 2 * __base::__block_size) + if (__back_spare() >= 2 * __value_traits::__block_size) { - __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size); + __alloc_traits::deallocate(__a, __base::__map_.back(), __value_traits::__block_size); __base::__map_.pop_back(); } } @@ -2572,7 +2579,7 @@ while (__n > 0) { pointer __fb = __f.__ptr_; - pointer __fe = *__f.__m_iter_ + __base::__block_size; + pointer __fe = *__f.__m_iter_ + __value_traits::__block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -2634,7 +2641,7 @@ while (__n > 0) { pointer __fb = __f.__ptr_; - pointer __fe = *__f.__m_iter_ + __base::__block_size; + pointer __fe = *__f.__m_iter_ + __value_traits::__block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -2705,11 +2712,11 @@ __alloc_traits::destroy(__a, _VSTD::addressof(*__b)); --__base::size(); ++__base::__start_; - if (__front_spare() >= 2 * __base::__block_size) + if (__front_spare() >= 2 * __value_traits::__block_size) { - __alloc_traits::deallocate(__a, __base::__map_.front(), __base::__block_size); + __alloc_traits::deallocate(__a, __base::__map_.front(), __value_traits::__block_size); __base::__map_.pop_front(); - __base::__start_ -= __base::__block_size; + __base::__start_ -= __value_traits::__block_size; } } else @@ -2717,9 +2724,9 @@ iterator __i = _VSTD::move(_VSTD::next(__p), __base::end(), __p); __alloc_traits::destroy(__a, _VSTD::addressof(*__i)); --__base::size(); - if (__back_spare() >= 2 * __base::__block_size) + if (__back_spare() >= 2 * __value_traits::__block_size) { - __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size); + __alloc_traits::deallocate(__a, __base::__map_.back(), __value_traits::__block_size); __base::__map_.pop_back(); } } @@ -2744,11 +2751,11 @@ __alloc_traits::destroy(__a, _VSTD::addressof(*__b)); __base::size() -= __n; __base::__start_ += __n; - while (__front_spare() >= 2 * __base::__block_size) + while (__front_spare() >= 2 * __value_traits::__block_size) { - __alloc_traits::deallocate(__a, __base::__map_.front(), __base::__block_size); + __alloc_traits::deallocate(__a, __base::__map_.front(), __value_traits::__block_size); __base::__map_.pop_front(); - __base::__start_ -= __base::__block_size; + __base::__start_ -= __value_traits::__block_size; } } else @@ -2757,9 +2764,9 @@ for (iterator __e = __base::end(); __i != __e; ++__i) __alloc_traits::destroy(__a, _VSTD::addressof(*__i)); __base::size() -= __n; - while (__back_spare() >= 2 * __base::__block_size) + while (__back_spare() >= 2 * __value_traits::__block_size) { - __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size); + __alloc_traits::deallocate(__a, __base::__map_.back(), __value_traits::__block_size); __base::__map_.pop_back(); } } @@ -2781,9 +2788,9 @@ for (iterator __p = __b + __pos; __p != __e; ++__p) __alloc_traits::destroy(__a, _VSTD::addressof(*__p)); __base::size() -= __n; - while (__back_spare() >= 2 * __base::__block_size) + while (__back_spare() >= 2 * __value_traits::__block_size) { - __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size); + __alloc_traits::deallocate(__a, __base::__map_.back(), __value_traits::__block_size); __base::__map_.pop_back(); } } Index: test/std/containers/sequences/deque/deque.cons/incomplete.pass.cpp =================================================================== --- test/std/containers/sequences/deque/deque.cons/incomplete.pass.cpp +++ test/std/containers/sequences/deque/deque.cons/incomplete.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// deque() +// deque::iterator() + +#include +#include + +struct A { + std::deque d; + std::deque::iterator it; + std::deque::reverse_iterator it2; +}; + +int main() +{ + A a; + assert(a.d.size() == 0); + a.it = a.d.begin(); + a.it2 = a.d.rend(); +}