Getting a String Literal From an Aliased Template Mixin Parameter

jsako via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 14 19:57:53 PDT 2016


On Thursday, 15 September 2016 at 01:40:50 UTC, Anonymouse wrote:

> You mean, the literal string name of the original symbol you 
> passed as an alias? If so then you want the .stringof property.
>
> void main () {
> 	int first;
> 	bool second;
> 	string third;
> 	
> 	mixin Foo!(first, second, third);
> }
>
> mixin template Foo(alias abc, alias def, alias ghi)
> {
> 	static assert(abc.stringof == "first");
> 	static assert(def.stringof == "second");
> 	static assert(ghi.stringof == "third");
> }

Aha! Yes, that's exactly what I was looking for! Thanks!


More information about the Digitalmars-d-learn mailing list