inplace_merge, nWayUnion

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Aug 29 19:37:07 PDT 2010


On 08/29/2010 06:00 PM, bearophile wrote:
> 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

I haven't implemented inplace_merge yet. About nWayUnion - great idea, 
but don't ever come back with a bug report "nWayUnion is difficult to 
understand".

Andrei


More information about the Digitalmars-d mailing list