0

Is there any way to pass a compile time constant value to a constructor without making it a class template parameter?

The language does not let you pass explicit template parameters to constructors, and non-type template parameters have to be explicit.

struct Foo {
    template <int N>
    Foo() { bar<N>(); }
};

int main() {
    Foo<5> f{};  // error: 'Foo' is not a template
}
A-n-t-h-o-n-y
  • 410
  • 6
  • 14

0 Answers0