template this and traits getOverloads issue.
BBasile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Nov 20 07:42:59 PST 2015
On Friday, 20 November 2015 at 14:49:28 UTC, Adam D. Ruppe wrote:
> On Friday, 20 November 2015 at 14:01:13 UTC, BBasile wrote:
>> everything that can be done to avoid the compilations errors
>> will also prevent "bar" to be written in the output (because a
>> B will never be analyzed). The "only" fix I see is like in the
>> stack overflow answer: statically check if the mixin methods
>> are already there and remix the mixin in each descendant, so
>> that the getOverloads traits works on the right 'this'.
>
> Did you try using a template this parameter like I said in my
> comment?
>
> foreach(idx, overload; __traits(getOverloads, T,
> member))
> {
> auto dg = &(__traits(getOverloads, this_,
> member)[idx]);
Yes, using an index and a second call to getOverloads works,
"finally".
No need to remix. Thx. I hadn't understood what you meant on SO.
One last question: is it possible to nest the calls to functions
that take this kind of parameters ?
mixin template Bug()
{
void bug0(this T)(){}
void bug1(this T)(){}
void allbugs(this T)(){this.bug0(); this.bug1();}
}
I've tried different parameters and templates and it never works.
More information about the Digitalmars-d-learn
mailing list