template auto deduction

Alex sascha.orlov at gmail.com
Fri Oct 6 21:08:09 UTC 2017


Hey, template gurus :)

given this:

struct M(alias I : S!E, alias S, E...)
{
	R!E r;
	this(S)(S initStruct)    // line 4
	{
		r = R!E(initStruct);
	}
}
struct R(E...)
{
	this(S)(S initStruct)    // line 12
	{
		// do some cool stuff
	}
}
void main()
{
	FS!(Etype1) fs;
	auto m = M!(typeof(fs))(fs);    // line 21.
	auto a = M!(fs); // does not work
	auto b = M(fs); // does not work	
}
struct FS(T...){}
struct Etype1{}

Everything works as expected, especially line 21. The question is 
about syntactic sugar: What I have to change, to use auto 
deduction and to create the M struct like in line 22 or 23?

By the way, I'm aware, that the type matching in lines 4 and 12 
is lost, in the way it is written here. However, it is meant to 
exist, if this helps in some way...

Thanks a lot in advance
Alex


More information about the Digitalmars-d-learn mailing list