Tuple and tie?

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 8 14:06:41 PDT 2014


On Tue, Jul 08, 2014 at 07:46:14PM +0000, anonymous via Digitalmars-d-learn wrote:
> 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.

You're right! Shows how much I don't know, I guess. :P


T

-- 
There's light at the end of the tunnel. It's the oncoming train.


More information about the Digitalmars-d-learn mailing list