The following code is rejected with the message
test.cpp(19): error: declaration is incompatible with function template "void Foo::bar(Vec<, T>) [with N=0]" (declared at line 11) void Foo<0>::bar(Vec<0, T> x) {}
Compiled with: icpc -std=c++14 test.cpp
icpc --version
icpc (ICC) 17.0.2 20170213
Copyright (C) 1985-2017 Intel Corporation. All rights reserved.
constexpr int getN(int n) { return n; }; template<int N, typename T> struct Vec{ }; template<int N> struct Foo { template<typename T> void bar(Vec<getN(N), T> x); //// A workaround // static constexpr int n = getN(N); // template<typename T> void bar(Vec<n, T> x); }; template<> template <typename T> void Foo<0>::bar(Vec<0, T> x) {}
Thanks,
Matthias Hochsteger