can't use variadic template arg in dependent type [OT: C++ style declarations?]

Kyle Furlong kylefurlong at gmail.com
Mon Jan 8 15:02:52 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 :(
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> //Purpose:
> //  See if template function can take arg whose type
> //  is dependent on the template argument.
> 
>   class
> A
>   ( Targs...
>   )
> {
> }
> 
>   class
> B
>   ( Targ
>   )
> {
> }
> 
> void funA(Targs...)(in A!(Targs) a)
> {
> }
> 
> void funB(Targ)(in B!(Targs) a)
> {
> }
> 
> void test()
> {
>     A!(int,float) a_int_float;
>     funA(a_int_float);
>     B!(int) b_int;
>     funB(b_int);
> }
> 
> 
> ------------------------------------------------------------------------
> 
> cd /home/evansl/prog_dev/d-language/mpl/std/mpl/test/
> make variadic_dep_type-d.o
> /home/evansl/prog_dev/d-language/dmd/bin/dmd -c -I/home/evansl/prog_dev/d-language/dmd/src/phobos variadic_dep_type.d -ofvariadic_dep_type-d.o
> variadic_dep_type.d(30): template variadic_dep_type.funA(Targs...) does not match any template declaration
> variadic_dep_type.d(30): template variadic_dep_type.funA(Targs...) cannot deduce template function from argument types (A)
> make: *** [variadic_dep_type-d.o] Error 1
> 
> Compilation exited abnormally with code 2 at Mon Jan  8 15:49:38

Does the:

     class
AClass
     ( Args
     )
{
}

style that I've seen a few attachments use recently come from C++'s 
template nightmare? If so, please look at this:

class AClass(Args)
{
}

And let me know which is better! :D



More information about the Digitalmars-d mailing list