T : T*
Jonathan M Davis
jmdavisProg at gmx.com
Fri Apr 13 11:59:53 PDT 2012
On Friday, April 13, 2012 14:47:45 Jonathan M Davis wrote:
> I'd just like to verify that my understanding of T : T* in this template is
> correct:
>
> struct S(T : T*)
> {
> T t;
> }
>
> It's my understanding that it's requiring that the template argument be
> implicitly convertible to a pointer to that type. However, as this
> stackoverflow question shows:
>
> http://stackoverflow.com/questions/10145779/why-this-template-parameters-
> constraint-doesnt-work
>
> it appears that the compiler is instead taking this to mean that the pointer
> part of the type should be stripped from the template argument's type.
> Given some of the bizarre stuff that happens with is expressions and the
> like, it's not out of the question that I'm just misunderstanding what the
> compiler is supposed to do with T : T* in this case (though I don't think
> so), so I'd like to verify it.
Okay. Clearly, I'm misunderstanding this, because std.traits.pointerTarget
uses this idiom:
template pointerTarget(T : T*)
{
alias T pointerTarget;
}
Anyone know _why_ it works this way?
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list