I have the following class:
template<int p, int q, int r>
struct ga { // geometric algebra with signature (p,q,r)
static const int d = p+q+r;
struct mv { ... }; // multivector in this GA
template<int g>
struct gmv : mv { ... }; // multivector in this GA with grade g
};
And I want to make a function outside of this class that takes a ga::mv
a
template<int p, int q, int r>
void print(ga<p,q,r>::mv) { ... }
However this gives the following error message:
error: variable or field 'print' declared void
void print(ga<p,q,r>::mv v) {
^~~~~
error: expected ')' before 'v'
void print(ga<p,q,r>::mv v) {
~ ^~
)
These error messages seem weird to me and suggests the compiler is not properly parsing my code.
I also tried
template<int p,int q,int r, ga<p,q,r> g>
void print(g::mv v) { ... }
Giving the declared void error and also
error: 'g' is not a class, namespace, or enumeration
It works if I do
using pga = ga<3,1,0>
void print(pga::mv v) { ... }
So how can I implement the general version?
Edit: Full MRE
template<int p, int q, int r>
struct ga { // geometric algebra with signature (p,q,r)
static const int d = p+q+r;
struct mv {}; // multivector in this GA
template<int g>
struct gmv : mv {}; // multivector in this GA with grade g
};
template<int p, int q, int r>
void print(typename ga<p,q,r>::mv v) {}
int main() {
using pga = ga<3,1,0>;
pga::gmv<2> v;
print(v);
}
::mv) { }`
– 463035818_is_not_an_ai Sep 01 '23 at 11:51::mv` as the initializer for the variable `print` of type `void` and then complains that you cannot declare `print` to be of type `void`. The keyword `typename` helps the compiler to realize that `ga
::mv` is a type
– 463035818_is_not_an_ai Sep 01 '23 at 11:54::gmv` is a specialisation of `ga
– Jelmer Firet Sep 01 '23 at 12:27::mv`, But I guess that should be asked as a seperate question.
::mv` is not a type. It could be an `int` or anything else.
– 463035818_is_not_an_ai Sep 01 '23 at 12:53