digitalmars.D.bugs - Template problem
- David Medlock (19/20) Mar 09 2005 import std.stdio;
- xs0 (3/28) Mar 09 2005 It should be "char C" instead of "C : char"...
- David Medlock (7/15) Mar 09 2005 Thanks.
- xs0 (6/14) Mar 09 2005 C matches types
import std.stdio; template Test( C : char ) { void print() { writefln( C ); } } void main( char[][] arg ) { Test!('a').print(); } ---------- Capture Output ----------"C:\dmd\bin\dmd.exe" -debug -c C:\proj\temp\test.dC:\proj\temp\test.d(16): template instance Test!(97) does not match any template declaration C:\proj\temp\test.d(16): undefined identifier template instance Test!(97).print C:\proj\temp\test.d(16): function expected before (), not 'void' Anyone see what is wrong here?
Mar 09 2005
David Medlock wrote:import std.stdio; template Test( C : char ) { void print() { writefln( C ); } } void main( char[][] arg ) { Test!('a').print(); } ---------- Capture Output ---------- > "C:\dmd\bin\dmd.exe" -debug -c C:\proj\temp\test.d C:\proj\temp\test.d(16): template instance Test!(97) does not match any template declaration C:\proj\temp\test.d(16): undefined identifier template instance Test!(97).print C:\proj\temp\test.d(16): function expected before (), not 'void' Anyone see what is wrong here?It should be "char C" instead of "C : char"... xs0
Mar 09 2005
xs0 wrote:David Medlock wrote:Thanks. Don't know why I thought the : syntax was specialization.... What really threw me off is if you make it template Test( C ) it still fails, which is kind of weird, as there is no other Test template....Anyone see what is wrong here?It should be "char C" instead of "C : char"... xs0
Mar 09 2005
Don't know why I thought the : syntax was specialization.... What really threw me off is if you make it template Test( C ) it still fails, which is kind of weird, as there is no other Test template....C matches types char C matches actual chars (values) C : Type matches Type or its derivative (or maybe just Type, not sure) C : char matches just type char (not a char value or even char typedef) char C : 'a' matches the character 'a' xs0
Mar 09 2005