This is what I'm tying (and failing) to make work. The idea is that count<N> has to be equal to N. This is a simplified case of a more complex calculation, don't mind the apparent silliness of this code.
template <>
constexpr size_t count<0> = 0;
template <auto N>
constexpr size_t count = 1 + count<static_cast<size_t>(N) - 1>;
int main()
{
return count<1>;
}
It doesn't compile:
<source>:5:23: error: expected initializer before '<' token
constexpr size_t count<0> = 0;
^
If I swap the general case with the specialization, it also doesn't compile. Is it even doable with variable templates?