Boost logo

Boost Users :

Subject: [Boost-users] [BGL] Default-constructibility of vertices
From: Kelvin Chung (kelvSYC_at_[hidden])
Date: 2011-12-12 20:42:20


Suppose I have a class hierarchy, like so:

struct Foo {
        virtual Output doSomething(const Input& in);
};

class CompositeFoo {
        std::vector<Foo*> fooList; // Use your favorite smart pointer standin
for Foo* here
public:
        Output doSomething(const Input& in);
};

Now, suppose I have a functor:

class Functor {
        Foo* foo;
        Input input; // assume Input is copyable
public:
        Output operator()() { foo->doSomething(input); }
};

Now, the structure of doSomething() calls leads to a DAG structure with
Functor as the vertices. What I want to do is create a graph with BGL
that shows that structure, before topologically sorting it and doing
other stuff with it. However, it would appear that the vertices of the
graph (which I would assume to be of type
boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS,
Functor>) must be default-constructible, which Functor is clearly not.
Is there a nice workaround to this without changing the vertex type to
Functor* (again, use your favorite smart pointer standin for Functor*
here)?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net