Variadic Tuple of Structs with Mixed Types

Michael Coulombe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 15 10:41:21 PDT 2016


On Friday, 15 July 2016 at 17:00:09 UTC, jmh530 wrote:
> I was working with the lightweight wrapper and it seemed to 
> work for simple stuff, but then I started getting a bunch of 
> errors when I tried to integrate it in to my project.
>
> Below is the stripped down version of what I've been working 
> with. I think the problem is that I can't get the fillAliasSeq 
> template to work with aliases. If I change Foo to just take 
> types and pass something like int or float, then it works fine.
>
> Note, I originally had fillAliasSeq as a nested template within 
> bar, but this was causing errors similar to what is brought up 
> in this thread
> http://forum.dlang.org/post/mailman.578.1343005779.31962.digitalmars-d-learn@puremagic.com

Your issue is this line:

alias boxAR(A) = Box!(A, R);

This means that A must be a type, but you are trying to 
instantiate it with lambdas. If you switch to:

alias boxAR(alias A) = Box!(A, R);

But now you are back to the "local '__lambda1' as parameter to 
non-global template" error.

Have you considered recursive solutions?

template fillAliasSeq(R, f...)
{
	import std.meta : AliasSeq;
	
	static if (f.length == 0) {
	    alias fillAliasSeq = AliasSeq!();
     }
     else {
	    alias fillAliasSeq = AliasSeq!(Foo!(f[0], R), 
fillAliasSeq!(R, f[1..$]));
	}
}


More information about the Digitalmars-d-learn mailing list