On 06/10/12 19:45, Zhenya wrote: > On Sunday, 10 June 2012 at 17:34:19 UTC, Zhenya wrote: >> I read in documentation,that we have two ways to use mixin statement. >> 1st: mixin(string_wich_can_be_evaluated_at_compile_time); >> 2st:mixin template >> I could'nt find any information about such way to use it > > Also,in this case if we add "mixin" before template nothing will change. > So I would be grateful if you gave me some example,that help me see the > difference,becouse now I think that mixin templates is subset of regular > templates
A "normal" template just adds one or more compile-time parameters to a declaration. Which lets you acccess it as "template_name!(int)" and "template_name(double)" and the result is the same as if you had written the contents of template twice, once for ints and another copy for "double". Nothing more, every "template_name!(int)" refers to the same instance, which remains in the scope where it is defined. When you write "mixin template_name!(int)" then that templates content is copied instead, just if you copy-and-pasted it from where it's defined into the current scope and substituted "int" for the parameter. The compiler will also let you mixin a "normal" template, which is then treated just like it was a mixin-template, which may be confusing at first; this is why your program didn't fail to compile. The other way won't work BTW, you cannot use a mixin-template w/o mixin it in. artur