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

is there any way to pass t directly to A?

template A(T...) doesn't seem work nor does using an alias. (or at least, when I try to foreach over it, it doesn't work).


Reply via email to