Aliasing 'this' as a template parameter

Max Samuha maxter at i.com.ua
Thu Oct 19 11:00:10 PDT 2006


On Thu, 19 Oct 2006 16:46:12 +0300, Max Samuha <maxter at i.com.ua>
wrote:

>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.

Missing ! in mixin instantiations above



More information about the Digitalmars-d-learn mailing list