什么是惯用的 (a.k.a. "right") 方式将整数集合(或至少列表)作为 D 中的模板参数传递?

What is idiomatic (a.k.a. "right") way to pass set (or at least list) of ints as a template argument in D?

我需要将一组整数或整数列表作为模板参数传递给 class。我可以像在 C++ 中一样通过 Andrei Alexandrescu 的类型列表来做到这一点。但我认为这是重量级的解决方案。在 D 中是否有任何惯用的(更多 D-ish)方法?

可能您需要提供更完整的描述,但据我所知您可以使用:

class T(int[] C){
   this(){
      writeln("Array: ", C);
    }
}

最简单的方法是使用可变参数:

struct T(A...) {
}
T!(1, 2, 3, 4, 5) object;