[Issue 10119] Add tuple overload which automatically captures the names of symbols

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 19 11:55:16 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10119


Jakob Ovrum <jakobovrum at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakobovrum at gmail.com


--- Comment #1 from Jakob Ovrum <jakobovrum at gmail.com> 2013-05-19 11:55:15 PDT ---
No, this instead. (per IRC request)

https://gist.github.com/JakobOvrum/5608585
------------------------------------------
import std.typecons : Tuple;
import std.typetuple : TypeTuple;

template NameTypePairs(alias front, vars...)
{
    private enum name = __traits(identifier, front);
    private alias pair = TypeTuple!(typeof(front), name);

    static if(vars.length == 0)
        alias NameTypePairs = pair;
    else
        alias NameTypePairs =  TypeTuple!(pair, NameTypePairs!vars);
}

auto tuplify(vars...)()
{
    return Tuple!(NameTypePairs!vars)(vars);
}

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


More information about the Digitalmars-d-bugs mailing list