The Standard documents the signature of std::advance as
template <class Iter, class Distance> constexpr void advance(Iter& i, Distance n);
Furthermore, it does not appear to put any restriction on what the type
of Distance should be. While it is understood that it should usually
be std::iterator_traits::difference_type, I couldn't find any wording
that mandates that. Similarly, I couldn't find wording that forces the
distance to be a signed type.
This patch changes std::advance to accept any type in the second argument,
which appears to be what the Standard mandates. I think it would be better
to at least restrict it to integral types, but that's not what the Standard
appears to say.
clang-format: please reformat the code
-TEST_CONSTEXPR_CXX17 -void check_advance(It it, Distance n, It result) -{ - static_assert(std::is_same<decltype(std::advance(it, n)), void>::value, ""); - std::advance(it, n); - assert(it == result); +TEST_CONSTEXPR_CXX17 void check_advance(It it, Distance n, It result) { + static_assert(std::is_same<decltype(std::advance(it, n)), void>::value, ""); + std::advance(it, n); + assert(it == result);