标签: c++ templates constructor c++17
有什么方法可以将编译时常量值传递给构造函数而不使其成为类模板参数?
该语言不允许您将显式模板参数传递给构造函数,非类型模板参数必须是显式的。
struct Foo { template <int N> Foo() { bar<N>(); } }; int main() { Foo<5> f{}; // error: 'Foo' is not a template }