namespace std::ranges {
template<input_or_output_iterator I, sentinel_for<I> S>
subrange(I, S) -> subrange<I, S>;
template<input_or_output_iterator I, sentinel_for<I> S>
subrange(I, S, make-unsigned-like-t<iter_difference_t<I>>) ->
subrange<I, S, subrange_kind::sized>;
template<borrowed_range R>
subrange(R&&) ->
subrange<iterator_t<R>, sentinel_t<R>, (sized_range<R> || sized_sentinel_for<sentinel_t<R>, iterator_t<R>>) ? subrange_kind::sized : subrange_kind::unsized>;
template<borrowed_range R>
subrange(R&&, make-unsigned-like-t<range_difference_t<R>>) ->
subrange<iterator_t<R>, sentinel_t<R>, subrange_kind::sized>;
}
概要
subrange
クラステンプレートの型推論補助。
例
#include <ranges>
#include <concepts>
int main()
{
int a[] = {1, 2, 3};
std::ranges::subrange sub = a;
static_assert(std::same_as<
decltype(sub),
std::ranges::subrange<int*, int*, std::ranges::subrange_kind::sized>
>);
}
出力
バージョン
言語
- C++20
処理系
- Clang: 13.0.0 ✅
- GCC: 10.1.0 ✅
- ICC: ?
- Visual C++: 2019 Update 10 ✅