[Issue 1390] New: Implicit Instantiation: delegate args from 2 template params

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 31 11:41:40 PDT 2007


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

           Summary: Implicit Instantiation: delegate args from 2 template
                    params
           Product: D
           Version: 1.020
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: webmaster at villagersonline.com


This is the first of a pair of implicit-instantiation-of-function issues I'm
going to open.  I don't know whether I should list them as bugs or feature
requests.  I'm going to open them as bugs, and they can be changed if
appropriate.



I stumbled across this problem when I tried to build a CurryTail template
(curry the *last* argument from a delegate).  In the code below, CurryTailAlt
will perform implicit template instantiation, but I don't like it because one
delegate argument (the tail argument) shows up in both the P and T template
parameters.  It seems to me that DMD could deduce the template parameters in my
preferred version (CurryTail):


CODE
===========
void delegate(U) CurryTail(A,U...)(void delegate(U,A) dg,A arg)
{
  return null;
}
void delegate(T[0..$-1]) CurryTailAlt(P,T...)(void delegate(T) dg,P arg)
{
  return null;
}

struct FooStruct
{
  void foo(uint i,char c) {}
}

void bar() {
  auto temp = new FooStruct;

  auto dg1 = CurryTail   !(char,uint)(&temp.foo, 'c'); // this works
  auto dg2 = CurryTailAlt            (&temp.foo, 'c'); // this works
  auto dg3 = CurryTail               (&temp.foo, 'c'); // this doesn't
}
=============

DMD OUTPUT
=============
implicit_instantiation1.d(20): template
implicit_instantiation1.CurryTail(A,U...) does not match any template
declaration
implicit_instantiation1.d(20): template
implicit_instantiation1.CurryTail(A,U...) cannot deduce template function from
argument types (void delegate((uint), char),char)
[russ at russ dmd_bugs]$ dmd -c implicit_instantiation1.d
implicit_instantiation1.d(20): template
implicit_instantiation1.CurryTail(A,U...) does not match any template
declaration
implicit_instantiation1.d(20): template
implicit_instantiation1.CurryTail(A,U...) cannot deduce template function from
argument types (void delegate((uint), char),char)


-- 



More information about the Digitalmars-d-bugs mailing list