Runtime heterogeneous collections?

Steven O oliver.steven at gmail.com
Thu Jan 17 02:21:21 UTC 2019


I want to create a heterogeneous collection of red-black trees, 
and I can't seem to figure out if it's possible.

I can easily do:

import std.container.rbtree;
import std.typecons;

void main()
{
     alias Rec_type = Tuple!(int, "x", int, "y", int, "z");
     RedBlackTree!Rec_type[1] test;
}

That works great, but I can only add red-black trees of Rec_type. 
What if I want the collection of red-black trees to be different? 
So if you printed out the collection of red-black trees you'd see 
something akin to:

// Formatted for easier reading
[
  RedBlackTree([Tuple!(int, "x", int, "y", string, "z")(1, 2, 
"abc")]),
  RedBlackTree([Tuple!(int, "x", int, "y", int, "z")(1, 2, 3)])
]

Is it possible to do this?


More information about the Digitalmars-d-learn mailing list