Template specialization and mixin templates
Ben Gertzfield
bgertzfield at gmail.com
Fri Mar 29 10:07:26 PDT 2013
Hi folks,
I ran into what I think might be a bug with template
specialization not applying when using a mixin template to
specialize a function.
Here's an example:
http://pastebin.com/Wp96KHAY
The output I get with dmd v2.061 seems to show that the compiler
only chooses a template specialization if a template mixin
defines both the most general function as well as the specialized
version.
In the example below, I would expect the second instance of
Bar.go(T) to be MakeGo.go(T : U).
$ rdmd templateSpecialization.d
Foo.go(T)
Foo.go(T : int)
Bar.go(T)
Bar.go(T : int)
Bar.go(T)
MakeGo2.go(T)
MakeGo2.go(T : U)
I chatted with Andrei, and he suggested this behavior seemed like
a bug. Anyway, the workaround is pretty easy (ensure we provide
both the general and specialized implementation of the method
when using a mixin template), but I wanted to send it to the
group to see if I'm missing something.
More information about the Digitalmars-d
mailing list