Boost logo

Boost Users :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2005-12-29 10:28:08


On Dec 23, 2005, at 8:25 AM, Nicola Vitacolonna wrote:
> template <typename VertexProperty = no_property>
> class MyGraphWrapper {
> private:
> typedef adjacency_list<vecS, listS, bidirectionalS,
> property<vertex_index_t, int, VertexProperty> > GraphImpl;
> // ...
> };
> [snip]
> My test compiled and it seems to run fine. Is it really possible/
> safe to mix bundle properties with property lists in this way?

Yes, this is correct.

> Or, is there a way to avoid property lists?

Not cleanly. You could aggregate an index property with the
VertexProperty class (or derive from VertexProperty), e.g.,

template<typename BaseProperty>
struct WrapVertexProperty : public BaseProperty
{
   WrapVertexProperty() : BaseProperty() { }
   WrapVertexProperty(const BaseProperty& bp) : BaseProperty(bp) { }

   std::size_t index; // your index property
};

template<>
struct WrapVertexProperty<no_property>
{
   WrapVertexProperty() {}
   WrapVertexProperty(const no_property&) {};

   std::size_t index; // your index property
};

This solution isn't quite perfect, unfortunately: algorithms that
look for a "vertex_index" property won't find
WrapVertexProperty<...>::index, so you'll have to supply vertex index
maps to your algorithms or have MyGraphWrapper convert requests for
"vertex_index" into requests for &WrapVertexProperty<...>::index.
This is on our TODO list to fix, so that bundled properties can
integrate more cleanly.

        Doug


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