[Issue 17015] New: support final switch in std.variant
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Dec 22 09:11:11 PST 2016
https://issues.dlang.org/show_bug.cgi?id=17015
Issue ID: 17015
Summary: support final switch in std.variant
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: greeenify at gmail.com
As e.g. in https://github.com/s-ludwig/taggedalgebraic:
final switch (taggedAny.kind) {
case Tagged.Kind.i:
// It's "int i"
break;
case Tagged.Kind.str:
// It's "string str"
break;
case Tagged.Kind.foo:
// It's "Foo foo"
break;
}
this has the advantage over visit that the compiler can enforce that all types
are covered.
--
More information about the Digitalmars-d-bugs
mailing list