Problem with "dependent" template classes and their instantiations

S

sschnug

Hallo,

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
think.

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

Thanks for every answer.

Sascha
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top