I tried to create a std::ranges::iota_view with a value and a bound:
#include <ranges>
#include <vector>
int main() {
std::vector v{1,2,3};
auto indices = std::ranges::views::iota(0, v.size());
}
But clang 11.0.0 fails to compile with the error message:
no viable constructor or deduction guide for deduction of template arguments of 'iota_view'
What am I doing wrong?
From https://en.cppreference.com/w/cpp/ranges/iota_view
Note that the [deduction] guide protects itself against signed/unsigned mismatch bugs, like
views::iota(0, v.size())
, where0
is a (signed) int andv.size()
is an (unsigned) std::size_t.
This will work:
auto indices = std::ranges::views::iota(0u, v.size());
^ unsigned zero literal