summaryrefslogtreecommitdiffstats
path: root/libcxx/include/algorithm
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include/algorithm')
-rw-r--r--libcxx/include/algorithm20
1 files changed, 14 insertions, 6 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 68173f472c8..475ba66ad38 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -1672,7 +1672,8 @@ search_n(_ForwardIterator __first, _ForwardIterator __last,
_Size __count, const _Tp& __value_, _BinaryPredicate __pred)
{
return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first, __last, __count, __value_, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
+ (__first, __last, __convert_to_integral(__count), __value_, __pred,
+ typename iterator_traits<_ForwardIterator>::iterator_category());
}
template <class _ForwardIterator, class _Size, class _Tp>
@@ -1681,7 +1682,8 @@ _ForwardIterator
search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_)
{
typedef typename iterator_traits<_ForwardIterator>::value_type __v;
- return _VSTD::search_n(__first, __last, __count, __value_, __equal_to<__v, _Tp>());
+ return _VSTD::search_n(__first, __last, __convert_to_integral(__count),
+ __value_, __equal_to<__v, _Tp>());
}
// copy
@@ -1839,8 +1841,10 @@ typename enable_if
!__is_random_access_iterator<_InputIterator>::value,
_OutputIterator
>::type
-copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
+copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
+ typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ _IntegralSize __n = __orig_n;
if (__n > 0)
{
*__result = *__first;
@@ -1862,8 +1866,10 @@ typename enable_if
__is_random_access_iterator<_InputIterator>::value,
_OutputIterator
>::type
-copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
+copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
+ typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ _IntegralSize __n = __orig_n;
return _VSTD::copy(__first, __first + __n, __result);
}
@@ -2055,7 +2061,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
{
- return _VSTD::__fill_n(__first, __n, __value_);
+ return _VSTD::__fill_n(__first, __convert_to_integral(__n), __value_);
}
// fill
@@ -2101,8 +2107,10 @@ generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
template <class _OutputIterator, class _Size, class _Generator>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
-generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
+generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
{
+ typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ _IntegralSize __n = __orig_n;
for (; __n > 0; ++__first, (void) --__n)
*__first = __gen();
return __first;
OpenPOWER on IntegriCloud