[Issue 4265] It should be possible to query template parameters with __traits

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 23 18:27:32 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=4265



--- Comment #10 from thelastmammoth at gmail.com 2013-06-23 18:27:31 PDT ---
(In reply to comment #8)
> (In reply to comment #5)
> > I can have a pull ready soon for 2 traits:
> 
> I managed to lose the branch where I implemented this. I think I only did it
> partially though.
> 
> @kenji: If you have this:
> 
> template T(Args...) { }
> struct S(Args...) { }
> alias Tint = T!int;
> alias Sint = S!int;
> 
> How do you get to the 'S' declaration from the instance? I want to implement
> these traits:
> 
> static assert(is(__traits(getTemplateSymbol, SInt) == S));
> static assert(is(__traits(getTemplateArgs, SInt) == int));
> 
> I've tried this in traits.c:
> 
> Dsymbol *s = getDsymbol(o);
> TemplateInstace *ti = s->isTemplateInstance();
> 
> However that only works for Tint, and not for Sint. 's' is actually a
> StructDeclaration for Sint, not a TemplateInstance.


I made a pull request for this and other traits. It's in std.traits, which IMO
is better than adding it to the compiler. 
https://github.com/D-Programming-Language/phobos/pull/1367

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list