D - Template specialization rules
- Daniel Yokomiso (34/34) Apr 21 2003 Hi,
Hi, According the documentation about template specialization the following code should print, instead of looping forever: Bug(T[]) Bug(T) module bug4; template Bug(T) { void doIt() { printf("Bug(T)\r\n"); } } template Bug(T : T[]) { private instance Bug(T) bug; void doIt() { printf("Bug(T[])\r\n"); bug.doIt(); } } int main() { instance Bug(int[]) arrayBug; arrayBug.doIt(); return 0; } The compiler is assuming T in Bug(T : T[]) to be int[], but it should be int, shouldn't it? If not, how can we access the array element type in such templates? Best regards, Daniel Yokomiso. "When you want to change the world, you don't see the dawn by getting up early - you see it by not sleeping through the night." --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.474 / Virus Database: 272 - Release Date: 18/4/2003
Apr 21 2003