Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
January 10, 2018 TransitiveBaseTypeTuple doesn't seemed to print the symbols as well. | ||||
---|---|---|---|---|
| ||||
I expect ["__ctor", "__dtor", "toString", "toHash", "opCmp", "opEquals"], instead I got ["toString", "toHash", "opCmp", "opEquals", "Monitor", "factory"] Care anyone explain why it is? Source is the following: import std.stdio; import std.traits; interface A { } class D : A { this() { } ~this() { } } void main() { alias TL = TransitiveBaseTypeTuple!D; for(int x = 0; x < TL.length; x++) { auto b = [__traits(allMembers, TL[0])]; writeln(b); } } |
January 10, 2018 Re: TransitiveBaseTypeTuple doesn't seemed to print the symbols as well. | ||||
---|---|---|---|---|
| ||||
Posted in reply to 12345swordy | On Wednesday, 10 January 2018 at 18:31:17 UTC, 12345swordy wrote:
> for(int x = 0; x < TL.length; x++)
> {
> auto b = [__traits(allMembers, TL[0])];
Simple mistake there...
|
January 10, 2018 Re: TransitiveBaseTypeTuple doesn't seemed to print the symbols as well. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 10 January 2018 at 18:45:17 UTC, Adam D. Ruppe wrote:
> On Wednesday, 10 January 2018 at 18:31:17 UTC, 12345swordy wrote:
>> for(int x = 0; x < TL.length; x++)
>> {
>> auto b = [__traits(allMembers, TL[0])];
>
>
> Simple mistake there...
I noticed, can't fix it cause it won't let me edit it.
This auto b = [__traits(allMembers, TL[0])];
is meant to be auto b = [__traits(allMembers, TL[x])];
|
January 10, 2018 Re: TransitiveBaseTypeTuple doesn't seemed to print the symbols as well. | ||||
---|---|---|---|---|
| ||||
Posted in reply to 12345swordy | On Wednesday, 10 January 2018 at 19:07:46 UTC, 12345swordy wrote:
> I noticed, can't fix it cause it won't let me edit it.
OK, I'd just use foreach there anyway tho (then it actually builds!).
But, hopefully once you get it running, you'll see that the base type tuple just gives the bases: it will print two lines, one for the base class Object and one for your interface A. Neither of them have constructors!
It won't print the class D itself....
|
January 10, 2018 Re: TransitiveBaseTypeTuple doesn't seemed to print the symbols as well. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Wednesday, 10 January 2018 at 19:26:58 UTC, Adam D. Ruppe wrote:
> On Wednesday, 10 January 2018 at 19:07:46 UTC, 12345swordy wrote:
>> I noticed, can't fix it cause it won't let me edit it.
>
> OK, I'd just use foreach there anyway tho (then it actually builds!).
>
> But, hopefully once you get it running, you'll see that the base type tuple just gives the bases: it will print two lines, one for the base class Object and one for your interface A. Neither of them have constructors!
>
> It won't print the class D itself....
You know a equivalent template that does that?
|
January 10, 2018 Re: TransitiveBaseTypeTuple doesn't seemed to print the symbols as well. | ||||
---|---|---|---|---|
| ||||
Posted in reply to 12345swordy | On Wednesday, 10 January 2018 at 20:38:20 UTC, 12345swordy wrote:
> You know a equivalent template that does that?
No, though you could just AliasSeq!(D, TransitiveBaseTypeTuple!D) and make it yourself.
Though note that __traits(allMembers, D) already includes all members, including those from base classes too, so you might just want to use that.
|
Copyright © 1999-2021 by the D Language Foundation