D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8144 - Lambda template instantiation at Tuple creation point
Summary: Lambda template instantiation at Tuple creation point
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-24 14:51 UTC by bearophile_hugs
Modified: 2020-01-31 08:04 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2012-05-24 14:51:45 UTC
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)
Comment 1 Nathan S. 2020-01-31 08:04:22 UTC
The example code has worked since DMD 2.063.