Are there some helpers in Phobos equivalent to std::set_difference of ugly c++

Ferhat Kurtulmuş aferust at gmail.com
Fri Feb 3 15:48:55 UTC 2023


I could not find a thing doing this. And I don't want to write it 
from scratch. Getting a range as output is ok too. What I need is 
the following:

```c++
     const std::vector<int> v1{1, 2, 5, 5, 5, 9};
     const std::vector<int> v2{2, 5, 7};
     std::vector<int> diff;

     std::set_difference(v1.begin(), v1.end(), v2.begin(), 
v2.end(),
                         std::inserter(diff, diff.begin()));
     print(v1, "∖ ");
     print(v2, "= ");
     print(diff, "\n");

     // yielding { 1 2 5 5 5 9 } ∖ { 2 5 7 } = { 1 5 5 9 }
```


More information about the Digitalmars-d-learn mailing list