Use Current Template as a Template Parameter to one of the Template Parameters
With template template parameter, you can do something like:
template<typename EdgeType>
struct Vertex {
std::vector<EdgeType> successors;
};
template<typename EdgeCostType, template <typename> class VertexWrapper>
struct Edge {
EdgeCostType cost;
VertexWrapper<Edge> source;
VertexWrapper<Edge> dest;
};
using myEdge = Edge<double, Vertex>;
using myVertex = Vertex<myEdge>;
yours simply works.. (but i don't know how to print and initialize member vector)
#include <vector>
#include <iostream>
using namespace std;
template<typename EdgeType>
struct Vertex {
vector<EdgeType> successors;
};
template<typename EdgeCostType, typename VertexWrapper>
struct Edge {
EdgeCostType cost;
VertexWrapper source;
VertexWrapper dest;
};
int main (){
Vertex<int> vertx = {{5}};
Edge<int, decltype(vertx)> ed = {7};
cout<< ed.cost <<"\n"; //cout<< ed.dest.successors<<"\n"; // not work, ask help!
}