_InputIterator
for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
{
- typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
while (__n > 0)
{
_Size __count, const _Tp& __value_, _BinaryPredicate __pred)
{
return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>
- (__first, __last, __convert_to_integral(__count), __value_, __pred,
+ (__first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred,
typename iterator_traits<_ForwardIterator>::iterator_category());
}
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, __convert_to_integral(__count),
+ return _VSTD::search_n(__first, __last, _VSTD::__convert_to_integral(__count),
__value_, __equal_to<__v, _Tp>());
}
>::type
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
- typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
if (__n > 0)
{
>::type
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
- typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
return _VSTD::copy(__first, __first + __n, __result);
}
_OutputIterator
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
{
- return _VSTD::__fill_n(__first, __convert_to_integral(__n), __value_);
+ return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_);
}
// fill
_OutputIterator
generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
{
- typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
for (; __n > 0; ++__first, (void) --__n)
*__first = __gen();
{
_LIBCPP_ASSERT(__orig_n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value,
"Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
- typedef decltype(__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
- __advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
+ _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
}
template <class _InputIter>
typename iterator_traits<_InputIter>::difference_type
distance(_InputIter __first, _InputIter __last)
{
- return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
+ return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
}
template <class _InputIter>
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+#include <iterator>
+
+#include "test_macros.h"
+
+struct Incomplete;
+template<class T> struct Holder { T t; };
+
+template<class>
+struct Intable {
+ operator int() const { return 1; }
+};
+
+int main() {
+ Holder<Incomplete> *a[2] = {};
+ Holder<Incomplete> **p = a;
+#if TEST_STD_VER >= 17
+ p = std::next(p);
+ p = std::prev(p);
+ p = std::next(p, 2);
+ p = std::prev(p, 2);
+#endif
+ std::advance(p, Intable<Holder<Incomplete> >());
+ (void)std::distance(p, p);
+}