inplace_merge, nWayUnion

bearophile bearophileHUGS at lycos.com
Sun Aug 29 16:00:00 PDT 2010


How do you perform with Phobos2 the C++ STL algorithm inplace_merge()?
http://www.cplusplus.com/reference/algorithm/inplace_merge/
If it is not present yet in Phobos2, then I'd like it eventually to be added.

-------------------

Regarding std.algorithm.nWayUnion, how do you merge iterables of different type that yield the same type?


import std.stdio, std.algorithm, std.range;
void main() {
    auto r1 = map!q{a * 2}(iota(10));
    auto r2 = map!q{a * 5}(iota(15));
    auto r12 = nWayUnion([r1, r2]); // can't work
    writeln(r12);
}


A differently designed nWayUnion() allows me to use ranges of different type:

nWayUnion(r1, r2, r3, ...)

Bye,
bearophile


More information about the Digitalmars-d mailing list