namespace std::ranges {
template<class T, class Bound = unreachable_sentinel_t>
repeat_view(T, Bound = Bound()) -> repeat_view<T, Bound>;
}
概要
repeat_viewクラステンプレートの型推論補助。
例
#include <iostream>
#include <ranges>
int main() {
auto r = std::ranges::repeat_view(42, 3);
for (int x : r) {
std::cout << x << std::endl;
}
}
出力
42
42
42
バージョン
言語
- C++23
処理系
- Clang: 17 ✅
- GCC: 13 ✅
- ICC: ?
- Visual C++: 2022 Update 6 ✅
参照
- LWG Issue 4053. Unary call to
std::views::repeatdoes not decay the argument- C++26で、
Boundにデフォルトテンプレート引数unreachable_sentinel_tとデフォルト引数Bound()が追加され、repeat_view(E)のように第2引数を省略した推論が可能になった
- C++26で、