Is it valid to use an identifier of a class, that is only declared but not defined, as template argument and for template specialization.
Something like that:
template<typename T>
class NodeInfo;
template<typename T>
class GraphInfo;
template<typename T>
class Graph {
public:
GraphInfo<T> graphInfo;
NodeInfo<T> nodeInfo;
};
// specialisation
class ContextInfo;
template <>
class NodeInfo<ContextInfo> {
public:
int a, b, c;
};
template <>
class GraphInfo<ContextInfo> {
public:
int a, b, c;
};
int main() {
Graph<ContextInfo> g;
}
This compiles fine without any warning in gcc 7, but I'm wondering if this is a valid thing to do or do I create some kind of undefined behavior with that?