summaryrefslogtreecommitdiffstats
path: root/libcxx/include/__bit_reference
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2012-05-10 14:55:00 +0000
committerHoward Hinnant <hhinnant@apple.com>2012-05-10 14:55:00 +0000
commit423a8d77332738bd2fd38a6e5a762bb189e3216c (patch)
tree66fc31b3d7a4ebcf5c6fd1d2e167c7288fcee1d8 /libcxx/include/__bit_reference
parentff15ef0c506e65a7ecff95f52356320a96a89e4b (diff)
downloadbcm5719-llvm-423a8d77332738bd2fd38a6e5a762bb189e3216c.tar.gz
bcm5719-llvm-423a8d77332738bd2fd38a6e5a762bb189e3216c.zip
Fix several bugs in find/count specialized for bits.
llvm-svn: 156546
Diffstat (limited to 'libcxx/include/__bit_reference')
-rw-r--r--libcxx/include/__bit_reference64
1 files changed, 32 insertions, 32 deletions
diff --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference
index 95a1007bee7..28dedfd85a3 100644
--- a/libcxx/include/__bit_reference
+++ b/libcxx/include/__bit_reference
@@ -146,11 +146,11 @@ private:
// find
-template <class _Cp>
-__bit_iterator<_Cp, false>
-__find_bool_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, _IsConst>
+__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
{
- typedef __bit_iterator<_Cp, false> _It;
+ typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
// do first partial word
@@ -180,11 +180,11 @@ __find_bool_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n
return _It(__first.__seg_, static_cast<unsigned>(__n));
}
-template <class _Cp>
-__bit_iterator<_Cp, false>
-__find_bool_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, _IsConst>
+__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
{
- typedef __bit_iterator<_Cp, false> _It;
+ typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
// do first partial word
@@ -193,7 +193,7 @@ __find_bool_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __
__storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
__storage_type __dn = _VSTD::min(__clz_f, __n);
__storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
- __storage_type __b = ~(*__first.__seg_ & __m);
+ __storage_type __b = ~*__first.__seg_ & __m;
if (__b)
return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
__n -= __dn;
@@ -210,17 +210,17 @@ __find_bool_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __
if (__n > 0)
{
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
- __storage_type __b = ~(*__first.__seg_ & __m);
+ __storage_type __b = ~*__first.__seg_ & __m;
if (__b)
return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
}
return _It(__first.__seg_, static_cast<unsigned>(__n));
}
-template <class _Cp, class _Tp>
+template <class _Cp, bool _IsConst, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-__bit_iterator<_Cp, false>
-find(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, const _Tp& __value_)
+__bit_iterator<_Cp, _IsConst>
+find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)
{
if (static_cast<bool>(__value_))
return __find_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
@@ -229,11 +229,11 @@ find(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, cons
// count
-template <class _Cp>
-typename __bit_iterator<_Cp, false>::difference_type
-__count_bool_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
+template <class _Cp, bool _IsConst>
+typename __bit_iterator<_Cp, _IsConst>::difference_type
+__count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
{
- typedef __bit_iterator<_Cp, false> _It;
+ typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
typedef typename _It::difference_type difference_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
@@ -260,11 +260,11 @@ __count_bool_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __
return __r;
}
-template <class _Cp>
-typename __bit_iterator<_Cp, false>::difference_type
-__count_bool_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
+template <class _Cp, bool _IsConst>
+typename __bit_iterator<_Cp, _IsConst>::difference_type
+__count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
{
- typedef __bit_iterator<_Cp, false> _It;
+ typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type;
typedef typename _It::difference_type difference_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
@@ -275,7 +275,7 @@ __count_bool_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type _
__storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
__storage_type __dn = _VSTD::min(__clz_f, __n);
__storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
- __r = _VSTD::__pop_count(~(*__first.__seg_ & __m));
+ __r = _VSTD::__pop_count(~*__first.__seg_ & __m);
__n -= __dn;
++__first.__seg_;
}
@@ -286,15 +286,15 @@ __count_bool_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type _
if (__n > 0)
{
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
- __r += _VSTD::__pop_count(~(*__first.__seg_ & __m));
+ __r += _VSTD::__pop_count(~*__first.__seg_ & __m);
}
return __r;
}
-template <class _Cp, class _Tp>
+template <class _Cp, bool _IsConst, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-typename __bit_iterator<_Cp, false>::difference_type
-count(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, const _Tp& __value_)
+typename __bit_iterator<_Cp, _IsConst>::difference_type
+count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)
{
if (static_cast<bool>(__value_))
return __count_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
@@ -1238,14 +1238,14 @@ private:
template <class _Dp, bool _IC1, bool _IC2> friend bool equal(__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC1>,
__bit_iterator<_Dp, _IC2>);
- template <class _Dp> friend __bit_iterator<_Dp, false> __find_bool_true(__bit_iterator<_Dp, false>,
+ template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>,
typename _Dp::size_type);
- template <class _Dp> friend __bit_iterator<_Dp, false> __find_bool_false(__bit_iterator<_Dp, false>,
+ template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>,
typename _Dp::size_type);
- template <class _Dp> friend typename __bit_iterator<_Dp, false>::difference_type
- __count_bool_true(__bit_iterator<_Dp, false>, typename _Dp::size_type);
- template <class _Dp> friend typename __bit_iterator<_Dp, false>::difference_type
- __count_bool_false(__bit_iterator<_Dp, false>, typename _Dp::size_type);
+ template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
+ __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
+ template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
+ __count_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
};
_LIBCPP_END_NAMESPACE_STD
OpenPOWER on IntegriCloud