[Issue 13372] traits parent does not work on eponymous templates

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 29 07:51:05 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=13372

--- Comment #4 from Mike Franklin <slavo5150 at yahoo.com> ---
(In reply to Basile B. from comment #2)
> =========
> import std.meta;
> 
> template Parent(T)
> {
>     alias Parent = AliasSeq!(__traits(parent, T))[0];
> }
> 
> unittest
> {
>     class A(T){}
>     static assert(A!int.stringof != Parent!(A!int).stringof);
> }
> =========
> 
> yields: Error: static assert  ("A!int" != "A!int") is false
> 
> 
> the longer form
> 
> =========
> import std.meta;
> 
> template Parent(T)
> {
>     alias Parent = AliasSeq!(__traits(parent, T))[0];
> }
> 
> unittest
> {
>     template B(T){class B{}}
>     alias T = B!int;
>     static assert(is(T));
>     static assert(T.stringof != Parent!T.stringof);
> }
> =========
> 
> yields: Error: static assert  ("B!int" != "B!int") is false

These two tests now pass in v2.078.1

--


More information about the Digitalmars-d-bugs mailing list