std::ranges::zip_view<Views...>:: size
From cppreference.net
C++
Ranges library
|
||||||||||||||||||||||
| Range primitives | |||||||
|
|||||||
| Range concepts | |||||||||||||||||||
|
|||||||||||||||||||
| Range factories | |||||||||
|
|||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||
| Helper items | |||||||||||||||||
|
|
||||||||||||||||
std::ranges::zip_view
| Member functions | ||||
|
zip_view::size
|
||||
| Deduction guides | ||||
| Iterator | ||||
| Member functions | ||||
| Non-member functions | ||||
| Sentinel | ||||
| Member functions | ||||
| Non-member functions | ||||
|
constexpr
auto
size
(
)
requires ( ranges:: sized_range < Views > && ... ) ; |
(1) | (C++23以降) |
|
constexpr
auto
size
(
)
const
requires ( ranges:: sized_range < const Views > && ... ) ; |
(2) | (C++23以降) |
zip_view
内の要素数を返します。各基盤(適応された)レンジが
sized_range
を満たす場合にのみ提供されます。
次と同等:
return std::apply ( [](auto... sizes) { using CT = /*make-unsigned-like-t*/<std::common_type_t<decltype(sizes)...>>; return ranges::min({CT(sizes)...}); }, /*tuple-transform*/(ranges::size, views_) );
目次 |
パラメータ
(なし)
戻り値
要素数。これは、すべての適応された
view
s
のサイズの中で最小のサイズです。
例
このコードを実行
#include <algorithm> #include <cassert> #include <deque> #include <forward_list> #include <ranges> #include <vector> int main() { auto x = std::vector{1, 2, 3, 4, 5}; auto y = std::deque{'a', 'b', 'c'}; auto z = std::forward_list{1., 2.}; auto v1 = std::views::zip(x, y); assert(v1.size() == std::min(x.size(), y.size())); assert(v1.size() == 3); [[maybe_unused]] auto v2 = std::views::zip(x, z); // auto sz = v2.size(); // エラー: v2はsize()メンバ関数を持たない static_assert(not std::ranges::sized_range<decltype(z)>); }
関連項目
|
(C++20)
|
範囲のサイズに等しい整数を返す
(カスタマイゼーションポイントオブジェクト) |
|
(C++20)
|
範囲のサイズに等しい符号付き整数を返す
(カスタマイゼーションポイントオブジェクト) |