Aliasing 'this' as a template parameter

Max Samuha maxter at i.com.ua
Thu Oct 19 06:46:12 PDT 2006


Walter, is it possible to make 'this' (and 'outer'?) aliasable in
templates? It would be useful when mixing code into class
declarations.

template TCode1()
{
	void wreck1()
	{
		char[] str = this.toString();
	}
}

template TCode2(alias Identifier)
{
	void wreck2(Identifier)
	{
		char[] str = Identifier.toString(); 
	}					
}

class Foo
{
	mixin TCode1(); // works ok
	mixin TCode2(this); // complains that 'this' is not in a
non-static member
	
	void foo()
	{
		mixin TCode2!(this); // complains that there's no
match			
	}	
}

Btw, thank you who reply to my posts and get no reply back from me.
It's not because i'm rude (well, i am in a way), i'm just still
desparately trying to make sense out of the thing called D and haven't
yet made enough progress for competent discussion.



More information about the Digitalmars-d-learn mailing list