[Issue 14191] New: Failure to locate overload with template this parameter
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Feb 16 19:46:48 PST 2015
https://issues.dlang.org/show_bug.cgi?id=14191
Issue ID: 14191
Summary: Failure to locate overload with template this
parameter
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: blocker
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: blah38621 at gmail.com
The following code fails to compile with:
Error: template main.C.myTemplate2 cannot deduce function from argument types
!()(int), candidates are:
main.C.myTemplate2(this P, T)(T val)
And the code:
void main(string[] args)
{
D.myTemplate3(0);
}
class C
{
static void myTemplate2(this P, T)(T val)
{
P.myTemplate(val);
}
}
class D : C
{
static void myTemplate3(T)(T val)
{
myTemplate2(val);
}
static void myTemplate(T)(T val)
{
}
}
Removing `this P` from the template parameter list of `myTemplate2` allows it
to compile, but doesn't give access to `myTemplate`.
This makes it very difficult to abstract out templated code into a base class
that is dependent upon the implementation in the derived class.
--
More information about the Digitalmars-d-bugs
mailing list