Let there be some template function foo with an integer argument of the template:
template <int N> void foo() { } Is it possible to write such a function / functional object void bar(...int n...) that will call the function foo<n> inside if the parameter n can be calculated at the compilation stage and there will be a compilation error if n not can be calculated.
As far as I understand, this behavior is unacceptable in modern standards (even including C ++ 17, despite the Class template argument deduction), but maybe there are concepts to future standards that allow such behavior?
Hack with #define not to offer, of course.
pow(a, b) = b^afor types for which typeb*bnot equal to the original typeb. You can write a function with thepow<a>(b), but then it will impose restrictions on a as a compile-time constant even for types that don't need it (int). - dortmundfooand if the parameterNcannot be calculated at the compilation stage, then there will be an error ... - VTTfoo<n>always imposes a restriction onnas a compile time constant. And I want to be able to impose a restriction sometimes. - dortmund