'how to set filter from another view?

std::vector v1 {4,2,7,6,4,1};
std::vector v2 {3,0,0,0,0,3};

I want to get the values in v1 with the condition v2=3

my desired result [4,1]

I tried with filter but it seems to work only with a specified value.

auto rng = v1 | ranges::views::filter([](int x){return ...;});

How can I do this without using for-loop?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source