inline constexpr /* unspecified */ iota = /* unspecified */;
Call signature
template< class W > requires /* see below */
requires /* see below */
1) A range factory that generates a sequence of elements by repeatedly incrementing an initial value. Can be either bounded or unbounded (infinite).
2) views::iota(e)and
views::iota(e, f)are
expression-equivalentto
iota_view<std::decay_t<decltype((e))>>(e)and
iota_view(e, f)respectively for any suitable subexpressions
eand
f.
Customization point objectsThe name views::iota
denotes a customization point object, which is a const function object of a literal semiregular
class type. See CustomizationPointObject for details.
W
value_
the beginning value
Bound
bound_
the sentinel value, may be unreachable
iota_view
iota_view
iota_view
iota_view
is empty (i.e. the iterator and the sentinel compare equal)
iota_view
(only provided if it is bounded)
std::ranges::view_interface<D>
) [edit] returns a sentinel for the constant iterator of the range
std::ranges::view_interface<D>
) [edit] returns whether the derived view is not empty, provided only if ranges::empty is applicable to it
std::ranges::view_interface<D>
) [edit] returns the first element in the derived view, provided if it satisfies forward_range
std::ranges::view_interface<D>
) [edit] returns the last element in the derived view, provided only if it satisfies bidirectional_range
and common_range
std::ranges::view_interface<D>
) [edit] returns the n
th element in the derived view, provided only if it satisfies random_access_range
std::ranges::view_interface<D>
) [edit] [edit] Deduction guides [edit] Nested classes the iterator type
iota_view
is bounded and Bound
and W
are not the same type
This specialization of ranges::enable_borrowed_range makes iota_view
satisfy borrowed_range
.
#include <algorithm> #include <iostream> #include <ranges> struct Bound { int bound; bool operator==(int x) const { return x == bound; } }; int main() { for (int i : std::ranges::iota_view{1, 10}) std::cout << i << ' '; std::cout << '\n'; for (int i : std::views::iota(1, 10)) std::cout << i << ' '; std::cout << '\n'; for (int i : std::views::iota(1, Bound{10})) std::cout << i << ' '; std::cout << '\n'; for (int i : std::views::iota(1) | std::views::take(9)) std::cout << i << ' '; std::cout << '\n'; std::ranges::for_each(std::views::iota(1, 10), [](int i){ std::cout << i << ' '; }); std::cout << '\n'; }
Output:
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
[edit] See also fills a range with successive increments of the starting valueview
consisting of a generated sequence by repeatedly producing the same value
view
that maps each element of adapted sequence to a tuple of both the element's position and its value
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4