KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I saw a blog post which used non-type variadic templates (currently not supported by gcc, only by clang). template <class T, size_t... Dimensions> struct MultiDimArray { /* ... */ }; The example in the post compiles fine but I failed to get it to work with function templates. Can anyone help figuring out the correct syntax (if such exists)? int max(int n) { return n; } // end condition template <int... N> // replacing int... with typename... works int max(int n, N... rest) // !! error: unknown type name 'N' { int tmp = max(rest...); return n < tmp? tmp : n; } #include <iostream> int main() { std::cout << max(3, 1, 4, 2, 5, 0) << std::endl; }
Tags (comma-separated)
Save Edits
Cancel