Hello!
I am trying to write a function template that takes a class template (with non-type arguments), and my brain (and Google) can't seem to find the right syntax for this.
A few lines of code is worth a thousand words, so here is a simplified example:
Code:
#include <iostream>
template <int X, int Y> struct A {};
template<A<int X, int Y>>
void f() { std::cout << X << ", " << Y << std::endl; }
int main() {
f<A<1, 2>>();
}
How do I make this work?
Error:
Code:
5:24: error: wrong number of template arguments (1, should be 2)
3:32: error: provided for 'template<int X, int Y> struct A'
6:8: error: two or more data types in declaration of 'f'
6:10: error: expected '>' before '{' token
6:10: error: expected unqualified-id before '{' token
In function 'int main()':
9:5: error: 'f' was not declared in this scope
9:13: error: expected primary-expression before '>' token
9:16: error: expected primary-expression before ')' token
Runnable example: C++ Shell
Thanks!
PS: Not sure if any of the regulars from years ago are still here, but if so, hi! I used to be very active here about 10 years ago... a lot has changed but coming back here is hitting me with nostalgia!