It would be convenient if I had a view which lets me examine the result of a set operation.
This is similar to std::set_union, std::set_difference, and std::set_intersection; however, it should not require modification or output into a new range.
Desired usage
int a[] {1, 2, 4, 8, 16};
int b[] {1, 8, 80};
auto i = views::set_intersection(a, b); // {1, 8}
auto u = views::set_union(a, b); // {1, 2, 4, 8, 16, 80}
auto d = views::set_difference(a, b); // {2, 4, 16}
// note: the following syntax should also work, like for all views:
// a | views::set_xyz(b)
Does such a thing exist in the standard library of any standard or perhaps in range-v3? If not, how do I make my own?
Yes, this currently works using
range-v3:Godbolt link
The WG21 paper p2760r1 puts this in Tier 3 (the lowest priority) for C++26 however.
Please also note that a view will not preserve the "set-ness" for formatting