overloads and parents. __traits confusion
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Aug 12 01:50:42 PDT 2014
On Tuesday, 12 August 2014 at 05:23:53 UTC, Dicebot wrote:
> On Monday, 11 August 2014 at 13:00:27 UTC, John Colvin wrote:
>> alias Parent = TypeTuple!(__traits(parent, foo!float))[0];
>
> Say hello to optional parens - you are trying to call
> foo!float() here and apply result to trait.
I thought so. Ugh.
This works though:
void foo(float v){}
void foo(int a){}
alias Parent = TypeTuple!(__traits(parent, foo))[0];
pragma(msg, __traits(getOverloads, Parent, "foo"));
so it seems that instantiated function templates in this case are
called parenthesis-free, whereas normal functions are passed by
name/alias/whatever.
All expressions that are used as compile-time args (whether in
udas, traits or as template arguments) should require parenthesis
to be called. Anything else is madness.
A!(foo1().foo2()) //pass result
A!(foo1.foo2()) //pass result
A!(foo1.foo2) //pass function
A!(foo1) //pass function
foo(foo1) //pass result
More information about the Digitalmars-d-learn
mailing list