Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 27, 2013 [Issue 10183] New: Eponymous template instance fails to match in parameter list of other templates | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10183 Summary: Eponymous template instance fails to match in parameter list of other templates Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: jakobovrum@gmail.com --- Comment #0 from Jakob Ovrum <jakobovrum@gmail.com> 2013-05-27 03:57:40 PDT --- Code: ---- struct A(T, Unused) { T t; } template B(T) { alias B = A!(T, void); } void foo(T)(A!T a) {} void main() { auto b = B!int(42); // OK, works foo(b); // NG - causes error } ---- Output: ---- test.d(18): Error: template test.foo does not match any function template declaration. Candidates are: test.d(12): test.foo(T)(A!(T) a) test.d(18): Error: template test.foo(T)(A!(T) a) cannot deduce template function from argument types !()(A!(int, void)) ---- Could be a duplicate, but I don't know what to search for. Does not appear to be a regression. The call to `foo` works when the second template parameter of A is removed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 27, 2013 [Issue 10183] Eponymous template instance fails to match in parameter list of other templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jakob Ovrum | http://d.puremagic.com/issues/show_bug.cgi?id=10183 --- Comment #1 from Jakob Ovrum <jakobovrum@gmail.com> 2013-05-27 04:07:18 PDT --- Thinking more about it, I guess this might not be meant to work. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 27, 2013 [Issue 10183] Eponymous template instance fails to match in parameter list of other templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jakob Ovrum | http://d.puremagic.com/issues/show_bug.cgi?id=10183 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2013-05-27 04:58:31 PDT --- (In reply to comment #0) > Code: > ---- > struct A(T, Unused) > { > T t; > } > > template B(T) > { > alias B = A!(T, void); > } > > void foo(T)(A!T a) {} The pattern A!T means that the template A has _exactly_ one type template argument. > void main() > { > auto b = B!int(42); // OK, works > > foo(b); // NG - causes error But the type of b is A!(int, void), so it does not match to A!T during IFTI. > } In this case, template function foo should have following signature. void foo(TL...)(A!TL a) {} // TL would be deduced to (int, void) or void foo(T, TL...)(A!(T, TL) a) {} // T would be deduced to int // TL would be deduced to (void) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 27, 2013 [Issue 10183] Eponymous template instance fails to match in parameter list of other templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jakob Ovrum | http://d.puremagic.com/issues/show_bug.cgi?id=10183 --- Comment #3 from Jakob Ovrum <jakobovrum@gmail.com> 2013-05-27 06:04:44 PDT --- Yeah, I noticed after posting. The problem with the amended caller code is that it leaks implementation details, as it were. It would be nice if there was a good way to solve this particular abstraction problem. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation