Re: Variant is just a class

2018-09-07 Thread Josphe Brigmo via Digitalmars-d
Here is a working example: import std.stdio; class Project(Wrapped, Interface) : Interface { import std.traits; Wrapped wrapped; static foreach (member; __traits(allMembers, Interface)) { static foreach (overload; __traits(getOverloads, Interface, member))

Re: Variant is just a class

2018-09-07 Thread Neia Neutuladh via Digitalmars-d
On Friday, 7 September 2018 at 23:37:05 UTC, Josphe Brigmo wrote: On Friday, 7 September 2018 at 18:18:50 UTC, Neia Neutuladh Algebraic!SomeInterface should allow anything that inherits from that interface (possibly with an explicit cast). It doesn't. I *did* say "possibly with an explicit

Re: Variant is just a class

2018-09-07 Thread Josphe Brigmo via Digitalmars-d
On Friday, 7 September 2018 at 18:18:50 UTC, Neia Neutuladh wrote: On Friday, 7 September 2018 at 03:04:19 UTC, Josphe Brigmo wrote: We are talking about two different things that are related: A variant holds a set of objects. Using VariantClass limits the types to a subset and allows for

Re: Variant is just a class

2018-09-07 Thread Neia Neutuladh via Digitalmars-d
On Friday, 7 September 2018 at 03:04:19 UTC, Josphe Brigmo wrote: We are talking about two different things that are related: A variant holds a set of objects. Using VariantClass limits the types to a subset and allows for inherited types to be added. Algebraic!SomeInterface should allow

Re: Variant is just a class

2018-09-06 Thread Josphe Brigmo via Digitalmars-d
On Thursday, 6 September 2018 at 20:25:18 UTC, Neia Neutuladh wrote: On Thursday, 6 September 2018 at 10:18:43 UTC, Josphe Brigmo wrote: Variants can hold an arbitrary set of types. I imagine that it is effectively just a type id and an object pointer!? It's a typeid and a static array

Re: Variant is just a class

2018-09-06 Thread Neia Neutuladh via Digitalmars-d
On Thursday, 6 September 2018 at 10:18:43 UTC, Josphe Brigmo wrote: Variants can hold an arbitrary set of types. I imagine that it is effectively just a type id and an object pointer!? It's a typeid and a static array large enough to hold any basic builtin type: the now-deprecated creal, a

Variant is just a class

2018-09-06 Thread Josphe Brigmo via Digitalmars-d
Variants can hold an arbitrary set of types. I imagine that it is effectively just a type id and an object pointer!? If so, then it really is just a special type of a class class. Let me explain: I have a class that will "hold/wrap" another class. I could hold them using a variant but