Can't use variadic arguments to functions that use templates

JS js.mdnq at gmail.com
Sat Jul 20 11:00:06 PDT 2013


On Saturday, 20 July 2013 at 17:39:59 UTC, bearophile wrote:
> JS:
>
>> variadic parameters are suppose to make life easier but it 
>> seems those don't work with templates.
>>
>> template A(int L) { ... }
>>
>> void foo(T)(string s, T t...)
>> {
>>   A!(t.length);
>>
>> }
>
> Try this:
>
>
> template A(size_t L) {
>     enum A = L;
> }
>
> void foo(T...)(string s, T t) {
>     auto n = A!(t.length);
> }
>
> void main() {
>     foo("x", 1, 2);
> }
>
>
> Bye,
> bearophile

;/ I could have swore I tried that ;/

Thanks though! ;)


More information about the Digitalmars-d-learn mailing list