Talk:cpp/ranges/zip view

Stanislaw (talk) 10:22, 24 November 2022 (PST) Stanislaw

Example from : 

#include #include #include #include #include #include #include void print(auto const rem, auto const& range) { for (std::cout << rem; auto const& elem : range) std::cout << elem << ' '; std::cout << '\n'; }   int main { auto x = std::vector{1, 2, 3, 4}; auto y = std::list{"α", "β", "γ", "δ", "ε"}; auto z = std::array{'A', 'B', 'C', 'D', 'E', 'F'}; print("Source views:", ""); print("x: ", x); print("y: ", y); print("z: ", z); print("\nzip(x,y,z):", ""); for (std::tuple elem : std::views::zip(x, y, z)) { std::cout << std::get<0>(elem) << ' ' << std::get<1>(elem) << ' ' << std::get<2>(elem) << '\n'; std::get(elem) += ('a' - 'A'); // modifies the element of z       } print("\nAfter modification, z: ", z); }

Error:

main.cpp: In function ‘int main’: main.cpp:26:67: error: ‘zip’ is not a member of ‘std::views’ 26 |    for (std::tuple elem : std::views::zip(x, y, z)) { |                                                                  ^

Compiler GCC v12.1 C++23

Can somebody help with issue where is zip?

Thank's


 * Right, views is not implemented in the online gcc-12.1. This is why we sometimes provide temporary links to Compiler Explorer, like this, so the users can check out the examples online.

Eventually, the situation may become even better if Compiler Explorer be attached to cppreference directly, to enjoy the latest gcc/clang/msvc... versions with all the most recent features on.


 * --Space Mission (talk) 11:07, 24 November 2022 (PST)
 * re directly using Compiler Explorer - last time I asked (on cpp slack), Godbolt said anytime. Someone just has to do the magic --Cubbi (talk) 20:27, 24 November 2022 (PST)