How to test for equality of types?

Philippe Sigaud philippe.sigaud at gmail.com
Sat May 19 00:05:54 PDT 2012


On Fri, May 18, 2012 at 11:51 PM, Simen Kjaeraas <simen.kjaras at gmail.com> wrote:

> Because Wrapper!(AliasStruct).Wrap does not exist. And _error_ is not
> equal to any other type.

Yes. Wrap is included in the complete template name (Wrapper!(Wrap))
and has no independent existence.
You _can_ get access to it by exposing it as an alias, as you do in AliasStruct:

struct Wrapper(Wrap)
{
    alias Wrap Wrapped; // cannot call it 'Wrap'
 ...

}


(third case)
>> false
>
>
> And here I disagree. This prints true on 2.059. Regression?

AFAICT, this should print true.

And, concerning Artur questio, on 2.059 (Linux):

 pragma(msg, is(w._wrap.Alias == AliasStruct.Alias));//   -> true
 pragma(msg, typeof(w._wrap).Alias.stringof); // -> MyStruct
 pragma(msg, AliasStruct.Alias.stringof); // -> MyStruct


More information about the Digitalmars-d-learn mailing list