Problem with "dependent" template classes and their instantiations




i'm trying to implement a hypergraph data structure with the help of
templates, for a variable decision of the used stl containers.

Very simple Template tests, with classes and functions seem to work,
but i don't have any idea how to solve this issue.

Here's a simplified version of my problem:

There is a class Vertex, which holds an unsigned int identity and a
"template container" of pointers to a "template class Edge.
This class Edge should hold an array (size is limited) of pointers /
iterators (Vertex are part of class Vertices, which holds the Vertex
objects in a container) to "template class Vertex".
=> really circular

Something like this:

template < typename Type >
class Edge{
Type * adjacentVertices; // Array of
Pointers / Iterators to class objects of type Vertex

template < template < typename> class Container, typename Type >
class Vertex{
unsigned int identity;

Container<Type> adjacentEdges; // Container of Pointers
to class objects of type Edge

Now my question is: How to instantiate something like that?

typedef Vertex<std::vector<Edge ...??
Seems to be circular for me and i don't know how to split these
things with temporary typdefs? Forward declaring is also useless i

Next Question: Is this template parameter form avobe suggestive?
(passing the types for the pointers as template arguments) Any better

Thanks for every answer.



Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question