Is it possible to use a variable template inside the constexpr built-in function without displaying 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 does not 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 is that template declarations are not allowed in the block area (GCC gives an informative error message, Clang does not).
To repeat the motivation in more detail, this function is built-in and defined in the header, and I'm not interested in placing the variable template wherever the header is included.
I suppose that I can define the namespace of the parts and place the variable template there, but it would be better not to expose the variable template at all. Perhaps this is not possible.