VCCC  2024.05
VisualCamp Common C++ library
ranges::iota_view, views::iota

a view consisting of a sequence generated by repeatedly incrementing an initial value More...

Detailed Description

A range factory that generates a sequence of elements by repeatedly incrementing an initial value. Can be either bounded or unbounded (infinite).

Example

#include <algorithm>
#include <iostream>
#include <ranges>
struct Bound {
int bound;
// Since C++20
bool operator==(int x) const { return x == bound; }
// Until C++20
bool operator!=(int x) const { return x != bound; }
friend constexpr bool operator==(int x, Bound b) { return x == b.bound;}
friend constexpr bool operator!=(int x, Bound b) { return x != b.bound;}
};
int main()
{
for (int i : std::ranges::iota_view<int, int>{1, 10})
std::cout << i << ' ';
std::cout << '\n';
for (int i : std::views::iota(1, 10))
std::cout << i << ' ';
std::cout << '\n';
// C++17
for (int i : std::views::iota(1, Bound{10}))
std::cout << i << ' ';
std::cout << '\n';
// C++20
for (int i : std::views::iota(1) | std::views::take(9))
std::cout << i << ' ';
std::cout << '\n';
// Not implemented yet
{
std::cout << i << ' ';
});
std::cout << '\n';
}
constexpr VCCC_INLINE_OR_STATIC detail::for_each_niebloid for_each
Definition: for_each.hpp:54
constexpr VCCC_INLINE_OR_STATIC detail::iota_niebloid iota
Definition: iota_view.hpp:539
constexpr VCCC_INLINE_OR_STATIC detail::take_niebloid take
Definition: take.hpp:177
constexpr bool operator!=(const MatrixBase< E1 > &lhs, const MatrixBase< E2 > &rhs)
Definition: mat_expr_operations.hpp:23
constexpr bool operator==(const MatrixBase< E1 > &lhs, const MatrixBase< E2 > &rhs)
Definition: mat_expr_operations.hpp:15
See also
std::ranges::iota_view

Classes

class  iota_view< W, Bound >
 
struct  enable_borrowed_range< iota_view< W, Bound > >
 

Variables

constexpr VCCC_INLINE_OR_STATIC detail::iota_niebloid iota {}
 

Variable Documentation

◆ iota

constexpr VCCC_INLINE_OR_STATIC detail::iota_niebloid iota {}
constexpr

views::iota(e) and views::iota(e, f) are expression-equivalent to iota_view(e) and iota_view(e, f) respectively for any suitable subexpressions e and f