Suggested std.variant.Algebraic redesign
bearophile
bearophileHUGS at lycos.com
Sat Feb 23 17:35:56 PST 2013
Andrei Alexandrescu:
> alias Algebraic!(string, Tuple!(string, This[])) Tree;
>
> Needs a bugfix because of toString.
Filed:
http://d.puremagic.com/issues/show_bug.cgi?id=9580
Once issue 9580 is fixed it will allows a syntax:
import std.variant: Algebraic, This;
import std.typecons: tuple, Tuple;
alias Tree = Algebraic!(string, Tuple!(string, This[]));
void main() {
import std.stdio;
auto t = Tree("Sci-Fi",
[tuple("No", Tree("Action",
[tuple("Yes", Tree("Stallone")),
tuple("No", Tree("Schwarzenegger"))])),
tuple("Yes", Tree("Schwarzenegger"))]);
writeln(t);
}
Thank you,
bye,
bearophile
More information about the Digitalmars-d
mailing list