digitalmars.D.learn - TransitiveBaseTypeTuple doesn't seemed to print the symbols as well.
- 12345swordy (28/28) Jan 10 2018 I expect ["__ctor", "__dtor", "toString", "toHash", "opCmp",
- Adam D. Ruppe (2/5) Jan 10 2018 Simple mistake there...
- 12345swordy (5/11) Jan 10 2018 I noticed, can't fix it cause it won't let me edit it.
- Adam D. Ruppe (8/9) Jan 10 2018 OK, I'd just use foreach there anyway tho (then it actually
- 12345swordy (3/13) Jan 10 2018 You know a equivalent template that does that?
- Adam D. Ruppe (6/7) Jan 10 2018 No, though you could just AliasSeq!(D, TransitiveBaseTypeTuple!D)
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); } }
Jan 10 2018
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...
Jan 10 2018
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: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])];for(int x = 0; x < TL.length; x++) { auto b = [__traits(allMembers, TL[0])];Simple mistake there...
Jan 10 2018
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....
Jan 10 2018
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:You know a equivalent template that does that?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....
Jan 10 2018
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.
Jan 10 2018