Sometimes while I use templates, given a type I want to know what's the template it comes from. So in code like this: struct Foo(T) {} struct Bar(T) {} void main() { alias Foo!int Spam; } I want to know if Spam is an instantiation of Foo or Bar, and sometimes I'd even like to know the typetuple of arguments that has created Spam (here is (int,)). Currently there are some ways to solve this problem (and there's a module in dsource to find the typetuple of the instantiation template arguments), but I'd like a simple to use, robust, safe, and standard way in Phobos or in __traits, because I think this is a common enough need.
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/db88295013fabb9a31368af9cf02787125062df3 Fix Issue 5361 - Add TemplateOf and TemplateArgsOf Examples: ```d struct Foo(A, B) {} alias Bar = Foo!(int, real); static assert(__traits(isSame, TemplateOf!Bar, Foo)); static assert(is(TemplateArgsOf!Bar == TypeTuple!(int, real))); ``` https://d.puremagic.com/issues/show_bug.cgi?id=5361 https://github.com/D-Programming-Language/phobos/commit/e6e323175d8ea83aba09d85c6b927d61835c76c3 Merge pull request #1884 from Poita/bug5361 Fix Issue 5361 - Add TemplateOf and TemplateArgsOf