www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8144] New: Lambda template instantiation at Tuple creation point

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

           Summary: Lambda template instantiation at Tuple creation point
           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



I don't know if this is supposed to work, but it's handy:


import std.typecons: Tuple;
void main() {
    alias int function(int, int) Op;
    static void foo(Op o) {}
    foo((a, b) => a + b); // OK
    alias Tuple!(Op) T;
    auto t1 = T((int a, int b) => a + b); // OK
    auto t2 = T((a, b) => a + b); // Error
}


DMD 2.060alpha gives:

temp.d(8): Error: template std.typecons.Tuple!(int function(int,
int)).Tuple.__ctor does not match any function template declaration
...\dmd2\src\phobos\std\typecons.d(379): Error: template
std.typecons.Tuple!(int function(int, int)).Tuple.__ctor cannot deduce template
function from argument types !()(void)

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