digitalmars.D.learn - string to type
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (41/41) Feb 24 2021 Say, please,
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (5/8) Feb 24 2021 Simple version of this question is:
- =?UTF-8?B?0JLQuNGC0LDQu9C40Lkg0KTQsNC0?= =?UTF-8?B?0LXQtdCy?= (6/15) Feb 24 2021 I was stupid.
Say, please, how to convert string to type ? Is: interface IX { // } mixin template X() { // } // Mixin templates to class. // Scan class interfaces, then mix mixin template Members() { alias T = typeof( this ); static foreach ( IFACE; InterfacesTuple! T ) { pragma( msg, IFACE ); pragma( msg, IFACE.stringof[ 1 .. $ ] ); static if ( IFACE.stringof.length > 1 && IFACE.stringof[ 1 .. $ ] ) { mixin ( IFACE.stringof[ 1 .. $ ] )!(); // <-- HERE TROUBLE } } } class A : IX { mixin Members!(); } Want: // Mixin template mixin IFACE.stringof[ 1 .. $ ] !(); Got: Compilation error: "declaration expected" source: https://run.dlang.io/is/smFaWc Help wanted.
Feb 24 2021
On Thursday, 25 February 2021 at 06:51:11 UTC, Виталий Фадеев wrote:Say, please, how to convert string to type ? [...]Simple version of this question is: string t = "X"; mixin t!(); // <-- HERE TROUBLE
Feb 24 2021
On Thursday, 25 February 2021 at 06:53:28 UTC, Виталий Фадеев wrote:On Thursday, 25 February 2021 at 06:51:11 UTC, Виталий Фадеев wrote:I was stupid. Solution is: mixin ( "mixin " ~ IFACE.stringof[ 1 .. $ ] ~ "!();" ); Thanks!Say, please, how to convert string to type ? [...]Simple version of this question is: string t = "X"; mixin t!(); // <-- HERE TROUBLE
Feb 24 2021