Reputation: 1495
Look at following code:
template <typename T, int d>
class Grid {
//Following line is what I need to change
template<int d2> friend class Iterator<T,d,d2>;
}
template <typename T, int d, int d2>
class Iterator{
//some code that use private fields of Grid<T,d>
}
template <typename T, int d>
class Iterator<T,d,0>{
//This specialized class also need to use private parts of Grid<T,d>
}
Both specialized and not specialized Iterator should have access to private parts. Line:
template<int d2> friend class Iterator<T,d,d2>;
does not compile with error: partial specialization `Iterator' declared friend
Does anybody know how to replace it?
EDIT: Thanks to @Xeo comment i was able to make a workaround:
template<typename TT, int dd, int d2> friend class Iterator;
However this gives friend access to all Iterator templates not only to those one that have matching first and second template parameter.
Upvotes: 1
Views: 139
Reputation: 1495
This is just a workaround but it is working:
template<typename TT, int dd, int d2> friend class Iterator;
Upvotes: 1