std::ranges::iota_view
的推導指南
來自 cppreference.com
定義於標頭檔案 <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); }