On Thursday, 17 January 2019 at 02:27:20 UTC, Neia Neutuladh wrote:
On Thu, 17 Jan 2019 02:21:21 +0000, Steven O wrote:
I want to create a heterogeneous collection of red-black trees, and I can't seem to figure out if it's possible.

RedBlackTree!int and RedBlackTree!string are entirely different types (they just happen to be generated from the same template).

There are two reasonable ways of doing things:

1. Make a wrapper class. Now you can store Object[], or you can make a
base class or base interface and use that.
2. Use Variant, which can wrap anything, or the related Algebraic, which
can wrap a fixed collection of types.

You can use this technique either with the collection types themselves or with the value types.

As the OP is most likely looking for Variant, let me link to it:

https://dlang.org/phobos/std_variant.html#Variant

Reply via email to