can't use variadic template arg in dependent type

Daniel Keep daniel.keep+lists at gmail.com
Tue Jan 9 01:15:49 PST 2007


Larry Evans wrote:
> The code in 1st attachment compiles with output in 2nd attachment.
> Is this a bug?  It seems that a sysmbol representing a variadic
> temmplate arg can't be used to form a dependent type (IOW, Targs
> can't be used to form A!(Targs) ).  This is in contrast to
> how non-variadic symbols are treated :(

Ok, it took me a while, but I think I see what you're trying to do here. 
  Have you tried something along these lines:

 > class A(Targs...)
 > {
 >     private static alias Targs _Targs;
 > }
 >
 > void funA(Ttype)(in Ttype a)
 > {
 >     alias Ttype._Targs Targs;
 > }

If you really want to make sure that it's an A!(Targs), you could try this:

 > static if( !is( A!(Targs) == Ttype ) )
 >     static assert(false, "I can see through your clever deception!");

Sometimes you need to just accept any old type, and then prune it down 
with static assert(false)s to the types you actually want (just have a 
look at my previous poorly named post on holy bovines for some type 
madness).

Hope this helps,

	-- Daniel



More information about the Digitalmars-d mailing list