Bug 8144 – Lambda template instantiation at Tuple creation point
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-24T14:51:45Z
Last change time
2020-01-31T08:04:22Z
Assigned to
No Owner
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-05-24T14:51:45Z
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 by n8sh.secondary — 2020-01-31T08:04:22Z