inline constexpr /*unspecified*/ cartesian_product = /*unspecified*/;
Call signature
(since C++23)Helper concepts
(3) (exposition only*) (4) (exposition only*) template< bool Const, class First, class... Vs >concept /*cartesian-product-is-bidirectional*/ =
(ranges::bidirectional_range</*maybe-const*/<Const, First>> && ... &&
(ranges::bidirectional_range</*maybe-const*/<Const, Vs>> &&
concept /*cartesian-product-is-common*/ =
concept /*cartesian-product-is-sized*/ =
concept /*cartesian-is-sized-sentinel*/ =
(std::sized_sentinel_for<FirstSent</*maybe-const*/<Const, First>>,
ranges::iterator_t</*maybe-const*/<Const, First>>> && ... &&
(ranges::sized_range</*maybe-const*/<Const, Vs>> &&
std::sized_sentinel_for<ranges::iterator_t<
/*maybe-const*/<Const, Vs>>,
Helper function templates
(9) (exposition only*) 1)cartesian_product_view
is a range adaptor that takes
nview
s
, where
n > 0, and produces a
view
of tuples calculated by the
n-ary cartesian productof the provided ranges. The size of produced view is a multiple of sizes of provided ranges, while each element is a tuple (of references) of the size
n.
4)Determines if
cartesian_product
is a common range (see also
common_range
).
6)Determines if
cartesian_product
satisfies the helper concept
/*cartesian-product-is-common*/(see also
common_range
).
7)Determines if
cartesian_product
is a sized range (see also
sized_range
).
8) Determines if cartesian_product
uses sized sentinel.
Returns the end of the produced
view
. Participates in overload resolution only if
cartesian_product
satisfies the helper concept
/*cartesian-product-common-arg*/.
The First
range
passed to cartesian_product_view
is treated specially, since it is only passed through a single time. As a result, several constrains are relaxed on it:
First
is an input_range
instead of forward_range
;First
does not have to be a sized_range
in order for the cartesian_product_view
to be random_access_range
or common_range
;First
does not have to be common_range
in order for the cartesian_product_view
to be bidirectional_range
.The name views::cartesian_product
denotes a customization point object, which is a const function object of a literal semiregular
class type. See CustomizationPointObject for details.
base_
(private) An object that holds all adapted view
objects.
cartesian_product_view
sized_range
sized_range
or forward_range
std::ranges::view_interface<D>
) [edit] returns a constant iterator to the beginning of the range
std::ranges::view_interface<D>
) [edit] returns a sentinel for the constant iterator of the range
std::ranges::view_interface<D>
) [edit] returns whether the derived view is not empty, provided only if ranges::empty is applicable to it
std::ranges::view_interface<D>
) [edit] returns the first element in the derived view, provided if it satisfies forward_range
std::ranges::view_interface<D>
) [edit] returns the last element in the derived view, provided only if it satisfies bidirectional_range
and common_range
std::ranges::view_interface<D>
) [edit] returns the n
th element in the derived view, provided only if it satisfies random_access_range
std::ranges::view_interface<D>
) [edit] [edit] Deduction guides [edit] Nested classes the iterator type
#include <array> #include <iostream> #include <list> #include <ranges> #include <string> #include <vector> void print(std::tuple<char const&, int const&, std::string const&> t, int pos) { const auto& [a, b, c] = t; std::cout << '(' << a << ' ' << b << ' ' << c << ')' << (pos % 4 ? " " : "\n"); } int main() { const auto x = std::array{'A', 'B'}; const auto y = std::vector{1, 2, 3}; const auto z = std::list<std::string>{"α", "β", "γ", "δ"}; for (int i{1}; auto const& tuple : std::views::cartesian_product(x, y, z)) print(tuple, i++); }
Output:
(A 1 α) (A 1 β) (A 1 γ) (A 1 δ) (A 2 α) (A 2 β) (A 2 γ) (A 2 δ) (A 3 α) (A 3 β) (A 3 γ) (A 3 δ) (B 1 α) (B 1 β) (B 1 γ) (B 1 δ) (B 2 α) (B 2 β) (B 2 γ) (B 2 δ) (B 3 α) (B 3 β) (B 3 γ) (B 3 δ)[edit] References
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4