Search code examples
dtemplate-meta-programming

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


I need to pass a set of ints or list of ints to a class as a template argument. I can do this via Andrei Alexandrescu's type list as in C++. But I think it is heavyweight solution. Is there any idiomatic (more D-ish) way to do this in D?


Solution

  • May be you need provide more complete description, but as far as I can see you may use:

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