Is it possible to use a variable template inside an inline constexpr function without also exposing the variable template itself?
For example, this compiles and works:
template<typename T> constexpr T twelve_hundred = T(1200.0);
template<typename T>
inline constexpr T centsToOctaves(const T cents) {
return cents / twelve_hundred<T>;
}
But this doesn't compile:
template<typename T>
inline constexpr T centsToOctaves(const T cents) {
template<typename U> constexpr U twelve_hundred = U(1200.0);
return cents / twelve_hundred<T>;
}
The reason seems to be that template declarations aren't allowed in block scope (GCC gives an informative error message about this, Clang doesn't).
To repeat the motivation in a bit more detail, the function is inline and defined in a header, and I'm not interested in exposing the variable template wherever the header is included.
I guess I can define a detail namespace and put the variable template there, but it would be nicer not to expose the variable template at all. Maybe it's not possible.