Reputation: 1270
I am trying to get the difference between two ranges but have little luck. Something like
vector<int> l{ 1,5,6 };
auto diff = views::ints(1,10) - view::all( l );
==> Range<int> { 2,3,4,7,8,9 }
By the way. Are there any good writings on range-v3? Something to make me wiser?
Thanks.
Upvotes: 1
Views: 821
Reputation: 42554
You are looking for the set_difference
algorithm, or its lazy view
version:
#include <range/v3/view/iota.hpp>
#include <range/v3/view/set_algorithm.hpp>
#include <iostream>
#include <vector>
int main() {
std::vector<int> l{ 1,5,6 };
auto diff = ranges::view::set_difference(ranges::view::ints(1,10), l);
std::cout << diff << '\n'; // [2,3,4,7,8,9]
}
Upvotes: 1