April 13, 2008 Implicit template properties | ||||
|---|---|---|---|---|
| ||||
In the documentation on templates I read:
"Implicit Template Properties
If a template has exactly one member in it, and the name of that member is the same as the template name, that member is assumed to be referred to in a template instantiation:
template Foo(T)
{
T Foo; // declare variable Foo of type T
}
void test()
{
Foo!(int) = 6; // instead of Foo!(int).Foo
}"
What practical benefit does it serve having a template with a single member which has the same name as the template itself ? It does not appear that one can do anything with such a template.
| ||||
April 13, 2008 Re: Implicit template properties | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Edward Diener | Edward Diener wrote:
> In the documentation on templates I read:
>
> "Implicit Template Properties
> If a template has exactly one member in it, and the name of that member is the same as the template name, that member is assumed to be referred to in a template instantiation:
> template Foo(T)
> {
> T Foo; // declare variable Foo of type T
> }
> void test()
> {
> Foo!(int) = 6; // instead of Foo!(int).Foo
> }"
>
> What practical benefit does it serve having a template with a single member which has the same name as the template itself ? It does not appear that one can do anything with such a template.
Never mind ! I see the reason for it.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply