www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17015] New: support final switch in std.variant


          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 puremagic.com
          Reporter: greeenify gmail.com

As e.g. in https://github.com/s-ludwig/taggedalgebraic:

final switch (taggedAny.kind) {
    case Tagged.Kind.i:
        // It's "int i"

    case Tagged.Kind.str:
        // It's "string str"

    case Tagged.Kind.foo:
        // It's "Foo foo"

this has the advantage over visit that the compiler can enforce that all types
are covered.

Dec 22 2016