Namespaces
Variants

std::ranges::cartesian_product_view<First, Vs...>::cartesian_product_view

Von de.cppreference.net
 
 
Ranges-Bibliothek
Bereichsadapter
(seit C++23)(seit C++23)
(seit C++23)
(seit C++23)(seit C++23)
(seit C++23)(seit C++23)
(seit C++23)(seit C++23)
(seit C++23)(seit C++23)

 
 
constexpr cartesian_product_view() = default;
(1) (seit C++23)
constexpr explicit cartesian_product_view( First first_base, Vs... bases );
(2) (seit C++23)

Konstruiert ein cartesian_product_view.

1) Standardkonstruktor. Standard-initialisiert das zugrunde liegende Datenmember base_.
2) Move-konstruiert das zugrunde liegende base_ durch Initialisierung mit std::move(first_base), std::move(bases)....

Parameter

first_base - das erste View-Objekt zur Anpassung
bases - das Paket der View-Objekte zur Anpassung

Beispiel

#include <array>
#include <format>
#include <iostream>
#include <ranges>
#include <vector>
int main()
{
    auto x = std::array{'A', 'B'};
    auto y = std::vector{1, 2, 3};
    auto z = std::vector{-1, -2, -3};
    auto v = std::ranges::cartesian_product_view(x, y, z); // Überladung (2)
    for (int i{1}; auto const& [rx, ry, rz] : v)
        std::cout << std::format("({} {} {}){}", rx, ry, rz, (i++ % 3) ? ' ' : '\n');
}

Ausgabe:

(A 1 -1) (A 1 -2) (A 1 -3)
(A 2 -1) (A 2 -2) (A 2 -3)
(A 3 -1) (A 3 -2) (A 3 -3)
(B 1 -1) (B 1 -2) (B 1 -3)
(B 2 -1) (B 2 -2) (B 2 -3)
(B 3 -1) (B 3 -2) (B 3 -3)