Problem with "dependent" template classes and their instantiations

Discussion in 'C++' started by sschnug, Jan 10, 2009.

  1. sschnug

    sschnug Guest

    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
     
    sschnug, Jan 10, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mpichini
    Replies:
    0
    Views:
    402
    mpichini
    Jul 1, 2003
  2. Replies:
    1
    Views:
    272
    Victor Bazarov
    Oct 19, 2005
  3. sks
    Replies:
    3
    Views:
    414
  4. Imre
    Replies:
    8
    Views:
    313
  5. puzzlecracker
    Replies:
    1
    Views:
    537
    James Kanze
    Aug 7, 2008
Loading...

Share This Page