std.variant.Algebraic, self referential types and delegate members
Panke via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Nov 8 02:31:11 PST 2015
import std.variant, std.stdio;
---
struct NodeTypeA(T) { T[] children; }
struct NodeTypeB(T) { Tree children; }
struct Leaf(T) { T delegate() dg; }
alias Tree = Algebraic!(Leaf, NodeTypeA!This, NodeTypeB!This);
void main()
{
Tree t;
}
---
yields
tmp.d(6): Error: functions cannot return opaque type This by value
tmp.d(8): Error: template instance tmp.Leaf!(This) error
instantiating
This limitation seems arbitrary to me. What's the reason here?
More information about the Digitalmars-d-learn
mailing list