On Sun, 06 Nov 2011 14:34:33 +0100, J Arrizza <[email protected]> wrote:
Hi,
I'm trying to get the name of the surrounding class from within a static
method of the class:
import std.stdio;
void main(string[] args)
{
auto o = new SomeClass();
o.Run();
SomeClass.StaticRun();
}
class SomeClass
{
public void Run()
{
writeln("In Class non-static: ", typeid(typeof(this)));
}
public static void StaticRun()
{
writeln("In Class static: ", typeid(typeof(??)));
}
}
What do I use for "??" above.
Have you tried using this? It seems to work for me:
mixin template foo( ) {
static void baz( ) {
writeln( typeid(typeof( this ) ) );
}
}
class A {
mixin foo!();
}
void main( ) {
A.baz(); // prints bar.A
}