mixin on identifier

Johannes Totz johannes at jo-t.de
Mon Nov 21 16:02:34 PST 2011


On 21/11/2011 23:39, David Nadlinger wrote:
> Make T an alias parameter:
> class StateSet(alias T) { … }
>
> David

Thanks!

I was trying to get to something like this:

mixin template StateOne()
{
	int	value;
}

mixin template StateTwo()
{
	float	data;
}

class StateSet(alias T ...)
{
	mixin T;
}


int main(string[] argv)
{
	StateSet!(StateOne, StateTwo)	s = new StateSet!(StateOne, StateTwo)();

	return 0;
}


With the docs I got to:

template StateSet(alias T, S ...)
{
class StateSet
{
	mixin T;
}
}

But I have no clue how to expand S into mixin statements.



> On 11/22/11 12:38 AM, Johannes Totz wrote:
>>
>> mixin template StateOne()
>> {
>> int value;
>> }
>>
>> class StateSet(T)
>> {
>> mixin T;
>> }
>>
>> int main(string[] argv)
>> {
>> StateSet!StateOne s = new StateSet!StateOne();
>>
>> return 0;
>> }
>



More information about the Digitalmars-d-learn mailing list