std::ranges::iota_view
的推导指引
来自 cppreference.cn
定义于头文件 <ranges> |
||
template< class W, class Bound > requires (!/*is-integer-like*/<W> || |
(自 C++20 起) | |
此推导指引为 iota_view
提供,以允许从初始值和边界值进行推导。
对于 /*is-integer-like*/ 和 /*is-signed-integer-like*/ 的定义,见 is-integer-like 。
注意,该指引保护自身免受符号不匹配引起的错误,例如 views::iota(0, v.size()),其中 0 是有符号的,而 v.size() 是无符号的。
[编辑] 示例
运行此代码
#include <cassert> #include <ranges> int main() { auto io = std::ranges::iota_view(1L, 7L); // deduces W and Bound as “long” assert(io.front() == 1L and io.back() == 6L); }