www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9839] New: std.traits.Select to alias variables too

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

           Summary: std.traits.Select to alias variables too
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



Currently Select can't be used with variable names:


import std.traits: Select;
void main() {
    uint[] a1;
    ulong[] a2;
    alias T = int;
    alias T1 = Select!(T.sizeof == uint.sizeof, uint, ulong);
    alias a = Select!(is(T1 == uint), a1, a2);
}



DMD 2.063alpha:

temp.d(7): Error: template instance Select!(true, a1, a2) Select!(true, a1, a2)
does not match template declaration Select(bool condition, T, F)



So I suggest to add an alias version of Select (in future when built-in types
will become alias-able, the Select without alias will be removed):


template Select(bool b, alias A1, alias A2) {
    static if (b)
        alias Select = A1;
    else
        alias Select = A2;
}

template Select(bool b, T1, T2) {
    static if (b)
        alias Select = T1;
    else
        alias Select = T2;
}

void main() {
    uint[] a1;
    ulong[] a2;
    alias T = int;
    alias T1 = Select!(T.sizeof == uint.sizeof, uint, ulong);
    alias a = Select!(is(T1 == uint), a1, a2);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 30 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9839


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
            Summary|std.traits.Select to alias  |std.traits.Select should be
                   |variables too               |able to select symbols



04:06:46 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1235

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 31 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9839




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/320b73a39d3950651c034a142b70d93b36a9ecb1
Fixes Issue 9839 - Select should be able to select symbols.

https://github.com/D-Programming-Language/phobos/commit/39dd56dc551248917c093838ab43fdaf34a5501d


Issue 9839 - Select should be able to select symbols.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 31 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9839


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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