How to define templates

Jarrett Billingsley jarrett.billingsley at gmail.com
Sun Mar 29 11:46:55 PDT 2009


On Sun, Mar 29, 2009 at 2:28 PM, Steve Teale
<steve.teale at britseyeview.com> wrote:
>
> OK, I didn't look there - perhaps a definition in 'Decalrations' would make thing easier.
>
> But then I wonder, since a plain old string is acceptable as a template parameter, why I can't use a statement that does not involve any of the other template arguments.

Because... templates don't contain statements?  I'm not sure what your
question is, or what not using T, U, and V have to do with it.

> Also, would it be reasonable for the compiler to issue a warning or error message to the effect that T, U, and V were never mentioned in the template body.

Same idea as function arguments or locals.  Just a QOI issue.

> What is the basic difference between Templates and Macros - the declarations thing is obviously crucial, but why?

That can't really be answered until macros make their way into the
language ;)  but templates parametrize declarations, whereas macros
parametrize arbitrary code.  A parametrized type is something very
different from arbitrary code.



More information about the Digitalmars-d mailing list