I have this code, successfully compiled with g++ 13.3.0.
template<typename T1>
class H1
{
template<typename T2>
class H2 {
void Hh(int) {}
};
};
// template<typename T3> // not compiling
class H3
{
template<typename T1>
template<typename T2>
friend void H1<T1>::H2<T2>::Hh(int); // The issue row 253
};
If uncomment “template<typename T3>” g++ return:
g++ -std=c++17 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Test1.d" -MT"src/Test1.o" -o "src/Test1.o" "../src/Test1.cpp"
../src/Test1.cpp:253:27: error: expected initializer before ‘<’ token
253 | friend void H1<T1>::H2<T2>::Hh(int);
| ^
What should change in friend definition?
New contributor
Emil Atanasov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2