struct _Indices
{
template<ranges::__detail::__is_integer_like _Tp>
+ requires __detail::__can_iota_view<_Tp>
[[nodiscard]] constexpr auto
operator() (_Tp __e) const noexcept
{ return iota(_Tp{}, __e); }
#include <ranges>
#include <type_traits>
-#include <vector>
+#include <stddef.h>
template <typename T>
constexpr bool test(T n) {
VERIFY(test<size_t>(44));
static_assert(test<size_t>(44));
}
+
+template<typename T>
+constexpr size_t test_wider(T n)
+{
+ // If indices(n) works, try again with ranges::distance(indices(n)),
+ // which will be a wider type, until we get to an unsupported type.
+ // This verifies that indices(n) is SFINAE-friendly, because otherwise we
+ // would get a hard error outside the immediate context checked by requires.
+ if constexpr (requires { std::views::indices(n); })
+ return test_wider(std::ranges::distance(std::views::indices(n)));
+ return sizeof(T);
+}
+
+static_assert(test_wider(0) > sizeof(long long));