Thread overview | |||||
---|---|---|---|---|---|
|
January 22, 2009 aliases and templates | ||||
---|---|---|---|---|
| ||||
I already read about "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 I guess the following is something similar, but why are aliases used here? template ParameterTypeTuple(dg) { static if (is(dg P == function)) alias P ParameterTypeTuple; else static if (is(dg P == delegate)) alias ParameterTypeTuple!(P) ParameterTypeTuple; else static if (is(dg P == P*)) alias ParameterTypeTuple!(P) ParameterTypeTuple; else static assert(0, "argument has no parameters"); } |
January 22, 2009 Re: aliases and templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | On Thu, Jan 22, 2009 at 10:56 AM, Trass3r <mrmocool@gmx.de> wrote:
> I already read about "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
>
> I guess the following is something similar, but why are aliases used here?
>
> template ParameterTypeTuple(dg)
> {
> static if (is(dg P == function))
> alias P ParameterTypeTuple;
> else static if (is(dg P == delegate))
> alias ParameterTypeTuple!(P) ParameterTypeTuple;
> else static if (is(dg P == P*))
> alias ParameterTypeTuple!(P) ParameterTypeTuple;
> else
> static assert(0, "argument has no parameters");
> }
>
Aliases are members too.
|
January 23, 2009 Re: aliases and templates | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | Trass3r Wrote:
> I already read about "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
>
> I guess the following is something similar, but why are aliases used here?
>
> template ParameterTypeTuple(dg)
> {
> static if (is(dg P == function))
> alias P ParameterTypeTuple;
> else static if (is(dg P == delegate))
> alias ParameterTypeTuple!(P) ParameterTypeTuple;
> else static if (is(dg P == P*))
> alias ParameterTypeTuple!(P) ParameterTypeTuple;
> else
> static assert(0, "argument has no parameters");
> }
Without the alias you will be declaring a variable.
With it you are aliasing a type.
|
Copyright © 1999-2021 by the D Language Foundation