get type name from current class at compile time?

Paul Backus snarwin at gmail.com
Sun Apr 25 02:45:38 UTC 2021


On Sunday, 25 April 2021 at 02:26:00 UTC, Jack wrote:
>
> doesn't this work when called from member in a derived class?
>
> ```d
>
> class A
> {
> 	void doSomething(this T)()
> 	{
> 		writefln("name = [%s]", __traits(identifier, T));
> 	}
> }
>
> class K : A
> {
> 	void baa()
> 	{
> 		doSomething();
> 	}
> }
> ```
>
> result in the error:
>
> Error: template `foo.A.doSomething` cannot deduce function from 
> argument types `!()()`,

It works if you call it with `this.doSomething()`: 
https://run.dlang.io/is/eIygNG


More information about the Digitalmars-d-learn mailing list