std::ranges::cartesian_product_view<First, Vs...>:: size
From cppreference.net
<
cpp
|
ranges
|
cartesian product view
C++
Ranges library
|
||||||||||||||||||||||
| Range primitives | |||||||
|
|||||||
| Range concepts | |||||||||||||||||||
|
|||||||||||||||||||
| Range factories | |||||||||
|
|||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||
| Helper items | |||||||||||||||||
|
|
||||||||||||||||
std::ranges::cartesian_product_view
| Member functions | ||||
|
cartesian_product_view::size
|
||||
| Deduction guides | ||||
| Iterator | ||||
| Member functions | ||||
| Non-member functions | ||||
|
constexpr
/* 説明を参照 */
size
(
)
requires /*cartesian-product-is-sized*/ < First, Vs... > ; |
(1) | (C++23以降) |
|
constexpr
/* 説明を参照 */
size
(
)
const
requires /*cartesian-product-is-sized*/ < const First, const Vs... > ; |
(2) | (C++23以降) |
要素数を返す。戻り値の型は実装定義の /*unsigned-integer-like*/ 型 U である。
bases_
を基となるビューのタプルとし、
prod
を
bases_
内の全範囲のサイズの積とする。
1,2)
prod
を返す。
prod
が戻り値の型
U
で表現できない場合、動作は未定義である。
以下と等価:
return [&]<std::size_t... Is>(std::index_sequence<Is...>) { auto prod = static_cast<U>(1); prod = (static_cast<U>(ranges::size(std::get<Is>(bases_))) * ...); return prod; } (std::make_index_sequence<1U + sizeof...(Vs)>{});
目次 |
パラメータ
(なし)
戻り値
要素の数、すなわち、すべての基盤となる範囲のサイズの積。
注記
戻り値の型は、すべての基になる範囲の最大サイズの積を格納するのに十分な幅を持つ最小の /*unsigned-integer-like*/ 型です(そのような型が存在する場合)。
例
このコードを実行
#include <ranges> int main() { constexpr static auto w = {1}; constexpr static auto x = {2, 3}; constexpr static auto y = {4, 5, 6}; constexpr static auto z = {7, 8, 9, 10, 11, 12, 13}; constexpr auto v = std::ranges::cartesian_product_view(w, x, y, z); static_assert(v.size() == w.size() * x.size() * y.size() * z.size() and v.size() == 42); }
関連項目
|
(C++20)
|
範囲のサイズに等しい整数を返す
(カスタマイゼーションポイントオブジェクト) |
|
(C++20)
|
範囲のサイズに等しい符号付き整数を返す
(カスタマイゼーションポイントオブジェクト) |