T : T*
Jonathan M Davis
jmdavisProg at gmx.com
Fri Apr 13 12:42:48 PDT 2012
On Friday, April 13, 2012 21:04:07 Jakob Ovrum wrote:
> First, the argument type must match the form T*. The T can be any
> type; there is only one constraint here, the pointer head. So
> obviously, the argument type must be a pointer to anything to
> match T*, e.g. void*, shared(int)**, immutable(int)* etc. If it
> doesn't match, the template is dropped from the overload set.
>
> If it does match, the newly created symbol T refers to the role
> of T in the parameter specialization. For arguments void*,
> shared(int)** and immutable(int)*, that would be void,
> shared(int)* and immutable(int) respectively.
>
> Most forms of the `is` primary expression (IsExpression) are
> dedicated to allowing the same type inspection abilities (and
> some more) outside of template parameter lists, hence reading the
> documentation of IsExpression is a good idea [1]. In particular,
> it reveals that when the type specialization is dependent on the
> symbol identifier (e.g. there's a T in the T specialization) the
> resulting symbol refers to the deduced type; otherwise it is an
> alias of the type specialization, which explains the two uses you
> mention.
>
> [1] http://dlang.org/expression.html#IsExpression
Thanks for the info. Clearly, : does not mean quite the same thing in all
cases (in particular, when the same template parameter is on both sides of
it).
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list