<div class="gmail_quote">On Tue, Jun 25, 2013 at 3:47 AM, Dicebot <span dir="ltr"><<a href="mailto:public@dicebot.lv" target="_blank">public@dicebot.lv</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tuesday, 25 June 2013 at 10:32:14 UTC, Timothee Cour wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
template Test(alias T){<br>
  static if(is(T == TI!TP, alias TI, TP)){<br>
    enum Test=true;<br>
  }<br>
  else{<br>
    enum Test=false;<br>
  }<br>
}<br>
<br>
struct A(T){}<br>
void foo(T)(T a){}<br>
<br>
void main(){<br>
  static assert(Test!(A!double));<br>
  static assert(!Test!(foo!double)); //why is Test false?<br>
}<br>
<br></div><div class="im">
This is blocking my pull request to make<br>
fullyQualifiedName/<u></u>GetTemplateParent/<u></u>GetTemplateArguments work on<br>
everything: right now it fails on templated functions.<br>
</div></blockquote>
<br>
As I have already mentiond in comments to that pull (probably was not clear enough), it is not really a bug, but one of many difficulties when working with function types in generic code.<br>
<br>
When you pass a function there, you pass function symbol, not its type. For aggregates those are interchangeable, not so for functions. Most simple example:<br>
<br>
    void foo(int x) {}<br>
    pragma( msg, is(foo == function) ); // false<br>
    pragma( msg, is(typeof(foo) == function) ); // true<br>
<br>
So you simply can't do any type matching with T when T is function alias.<br>
<br>
However, when you take typeof(T), all template information gets lost and you get type of specific instantiation.<br>
<br>
Looks like not a bug, but lack of required tool.<br>
</blockquote></div><br><div><br></div><div><div>So how can I decompose alias fun=foo!double into <font color="#500050" face="arial, sans-serif">template parent / template arguments? </font></div><div><font color="#500050" face="arial, sans-serif">The compiler knows this so there has to be a way to retrieve it. If not, then we're back in my previous proposal, adding:</font></div>
<div><div><font color="#500050" face="arial, sans-serif">__traits(templateParent, symbol)</font></div></div></div><div><div><font color="#500050" face="arial, sans-serif">__traits(templateArguments, symbol)</font></div></div>
<div><font color="#500050" face="arial, sans-serif"><br></font></div>