Possible bug
Sergei Nosov
sergei.nosov at gmail.com
Tue Mar 26 00:34:55 PDT 2013
On Tuesday, 26 March 2013 at 05:40:00 UTC, Steven Schveighoffer
wrote:
> What you have to do is instantiate the template, then call the
> constructor:
>
> S!(int, 4).S!(byte, 5)(3)
>
> Note that the way templates work in D, a templated struct is
> really a shortcut for:
>
> template S(T)
> {
> struct S { ... }
> }
>
> So when you instantiate it, S!(int)(5) is really shorthand for
> S!(int).S(5).
>
> Every template is this way. The shorthand version calls on the
> "eponymous" member implicitly, that is, the member with the
> same name as the template. Currently, this only works if there
> is exactly one member.
>
> For example, a function template is really:
>
> template foo(T)
> {
> void foo(T t) {...}
> }
>
> So doing:
>
> foo!(int)(1)
>
> is really the same as:
>
> foo!(int).foo(1)
>
> It's all outlined here: http://dlang.org/template.html
>
> search for Implicit Template Properties
>
> -Steve
Thx a lot!
More information about the Digitalmars-d-learn
mailing list