Array literal template parameter?
bearophile
bearophileHUGS at lycos.com
Tue Nov 20 16:15:02 PST 2012
Maxime Chevalier:
> I need to pass an array literal as a template parameter. The
> reference on this website seems to imply this is possible, but
> doesn't illustrate it. The obvious way doesn't seem to work:
It's a known compiler bug, already in Bugzilla.
In the meantime this is a workaround:
template Foo(Args...) if (Args.length == 1) {
pragma(msg, Args[0]);
enum Foo = Args;
}
void main() {
enum double[] a = [10, 20, 30];
auto x = Foo!a;
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list