Template Declarations - Why not Template definitions?

WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 30 14:06:57 PDT 2015


All the stuff I've read about templates always refers to them as 
template declarations.

So with the following code segment:

template codeBlockTemplate(T, U)
{
     T a = 7;
     U b = 'z';
}

codeBlockTemplate!(int, char);  // error here

Microsof's Visual Studio IDE tells me <identifier> expected, ; 
found

But aren't templates instantiated at compile time? If so, isn't 
memory allocated at compile time, so in theory couldn't templates 
support code definitions?


Bonus question: Isn't a Zero-parameter template declaration 
pretty much worthless?

Thanks.








More information about the Digitalmars-d-learn mailing list