summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/include/__bit_reference
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2012-10-22 18:25:04 +0000
committerdim <dim@FreeBSD.org>2012-10-22 18:25:04 +0000
commit708d8e446e991358da23bb52ec5320440221f12f (patch)
tree3a061d75674cd5b60d9f6df45d0b8d755da3782f /contrib/libc++/include/__bit_reference
parentb8c74d455d2690e710a0802a98a9d310995a52eb (diff)
parent13334223d751d249ccd6475b8cba36ff71ddc972 (diff)
downloadFreeBSD-src-708d8e446e991358da23bb52ec5320440221f12f.zip
FreeBSD-src-708d8e446e991358da23bb52ec5320440221f12f.tar.gz
Import libc++ trunk r165949. Among other improvements and bug fixes,
this has many visibility problems fixed, which should help with compiling certain ports that exercise C++11 mode (i.e. Firefox). Also, belatedly add the LICENSE.TXT and accompanying CREDITS.TXT files, which are referred to in all the source files. MFC after: 1 month
Diffstat (limited to 'contrib/libc++/include/__bit_reference')
-rw-r--r--contrib/libc++/include/__bit_reference96
1 files changed, 51 insertions, 45 deletions
diff --git a/contrib/libc++/include/__bit_reference b/contrib/libc++/include/__bit_reference
index 48538a2..8180295 100644
--- a/contrib/libc++/include/__bit_reference
+++ b/contrib/libc++/include/__bit_reference
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Cp, bool _IsConst> class __bit_iterator;
+template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> class __bit_iterator;
template <class _Cp> class __bit_const_reference;
template <class _Tp>
@@ -131,13 +131,14 @@ public:
__bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
: __seg_(__x.__seg_), __mask_(__x.__mask_) {}
- _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
{return static_cast<bool>(*__seg_ & __mask_);}
_LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
{return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__ctz(__mask_)));}
private:
_LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_CONSTEXPR
__bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
: __seg_(__s), __mask_(__m) {}
@@ -146,11 +147,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 +181,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 +194,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 +211,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 +230,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 +261,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 +276,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 +287,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));
@@ -926,12 +927,12 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
// equal
-template <class _Cp>
+template <class _Cp, bool _IC1, bool _IC2>
bool
-__equal_unaligned(__bit_iterator<_Cp, true> __first1, __bit_iterator<_Cp, true> __last1,
- __bit_iterator<_Cp, true> __first2)
+__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
+ __bit_iterator<_Cp, _IC2> __first2)
{
- typedef __bit_iterator<_Cp, true> _It;
+ typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
@@ -1008,12 +1009,12 @@ __equal_unaligned(__bit_iterator<_Cp, true> __first1, __bit_iterator<_Cp, true>
return true;
}
-template <class _Cp>
+template <class _Cp, bool _IC1, bool _IC2>
bool
-__equal_aligned(__bit_iterator<_Cp, true> __first1, __bit_iterator<_Cp, true> __last1,
- __bit_iterator<_Cp, true> __first2)
+__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
+ __bit_iterator<_Cp, _IC2> __first2)
{
- typedef __bit_iterator<_Cp, true> _It;
+ typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word;
@@ -1061,7 +1062,8 @@ equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __b
return __equal_unaligned(__first1, __last1, __first2);
}
-template <class _Cp, bool _IsConst>
+template <class _Cp, bool _IsConst,
+ typename _Cp::__storage_type>
class __bit_iterator
{
public:
@@ -1232,19 +1234,23 @@ private:
template <class _Dp> friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
__bit_iterator<_Dp, false>,
__bit_iterator<_Dp, false>);
- template <class _Dp> friend bool __equal_aligned(__bit_iterator<_Dp, true>,
- __bit_iterator<_Dp, true>,
- __bit_iterator<_Dp, true>);
- template <class _Dp> friend bool __equal_unaligned(__bit_iterator<_Dp, true>,
- __bit_iterator<_Dp, true>,
- __bit_iterator<_Dp, true>);
+ template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
+ template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC1>,
+ __bit_iterator<_Dp, _IC2>);
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, 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