I want to implement generic graph classes and I am still having problems which narrowed down to the following code:
template <class T> class B
{
template <T> friend class A;
};
template <class T> class A
{
private:
std::vector<B<T> *> myBs;
};
class C { };
This compiles pretty well unless I do something like this:
B<C> myB;
... which causes the following errors:
B.h: In instantiation of ‘class B<C>’:
In file included from A.h:12:0,
from main.cpp:16:
main.cpp:30:10: required from here
B.h:15:1: error: ‘class C’ is not a valid type for a template non-type parameter
{
^
B.h:11:11: error: template parameter ‘class T’
template <class T> class A;
^
B.h:16:31: error: redeclared here as ‘<declaration error>’
template <T> friend class A;
Is my thinking absolutely wrong, am I missing something or is such a construct not possible, messy, odd or a very (...) very awful thing to do?