www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10127] New: TypeEnum in std.variant

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10127

           Summary: TypeEnum in std.variant
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: diggsey googlemail.com



It would be useful to use the tag part of a tagged union on its own, and it
would fit in well with the rest of std.variant.

It's not always the case that you want to store actual data, sometimes you just
need to store the type. Also sometimes you need to store the data somewhere
else or store it in such a way that you can specify the type first and fill in
the data later.

eg.
    alias TypeEnum!(
        void,
        byte,
        short,
        string,
        Object
    ) TestTypeEnum;

    TestTypeEnum test;

    assert(test == TestTypeEnum.from!void);
    assert(test != TestTypeEnum.from!byte);

    test = TestTypeEnum.from!string;

    assert(test == TestTypeEnum.from!string);
    assert(test != TestTypeEnum.from!Object);

    static assert(!__traits(compiles, TestTypeEnum.from!float));

(pull request shortly)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10127




https://github.com/D-Programming-Language/phobos/pull/1298

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21 2013