Regarding partition_copy

bearophile bearophileHUGS at lycos.com
Sun May 5 04:22:30 PDT 2013


Splitting a range in two according to a predicate is a common
enough need. How do you translate this C++/STL idiom to D/Phobos?


vector<int> source_data;
...
vector<int> good_stuff, bad_stuff;
partition_copy(begin(source_data), end(source_data),
                 inserter(good_stuff, end(good_stuff)),
                 inserter(bad_stuff, end(bad_stuff)),
                 is_good);


If this is not handy to implement with the current Phobos, is it
worth adding a similar function to Phobos?

Thank you,
bye,
bearophile


More information about the Digitalmars-d-learn mailing list