Tuple and tie?

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 8 12:46:14 PDT 2014


On Tuesday, 8 July 2014 at 19:40:59 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
> 	template TypesOf(T...)
> 	{
> 		static if (T.length == 1)
> 			alias TypesOf = typeof(T[0]);
> 		else
> 			alias TypesOf = TypeTuple!(typeof(T[0]), TypesOf!(T[1..$]));
> 	}
> 	
> 	@property void tie(T...)(Tuple!(TypesOf!T) t)
[...]
> It does involve some slightly more arcane template magic, 
> though. ;-)
> Basically, the TypesOf template transforms a list of alias 
> arguments
> into a list of the types of said arguments, so that we can 
> match a list
> of variables to the Tuple that is to be assigned to them.

typeof(T) would work, too.


More information about the Digitalmars-d-learn mailing list