How to extending algorithms with visitors

Hi all,
I'm enjoying learning the boost graph library. I'm
trying to use the Dijkstra algorithm and try to store
the shortest path as explained in the subsection
"Extending Algorithms with Visitors" of the section
"Quick Tour" of the BGL user guide.
When I try to compile my code, I get the following
error message:
mesh.cpp:38: error: expected constructor, destructor,
or type conversion before '<' token
mesh.cpp:38: error: expected `;' before '<' token
where line 38 is highlighted in the following portion
of code.
Could you help me to resolve this problem?
Thanks in advance,
Giulio
template <class PredecessorMap>
class record_predecessors : public dijkstra_visitor<>
{
public:
record_predecessors(PredecessorMap p)
: m_predecessor(p) { }
template

Hi Giulio, Glad you're enjoying the BGL :) Hmm, I don't see anything wrong... perhaps the error is even earlier in the source file, causing the compiler's parser to become very confused. If you want more help you'll need to send us a complete program that we can compile. Also, you'll need to tell us the compiler and its version number. Cheers, Jeremy On Sep 14, 2005, at 11:01 AM, Giulio Veronesi wrote:
Hi all,
I'm enjoying learning the boost graph library. I'm trying to use the Dijkstra algorithm and try to store the shortest path as explained in the subsection "Extending Algorithms with Visitors" of the section "Quick Tour" of the BGL user guide.
When I try to compile my code, I get the following error message:
mesh.cpp:38: error: expected constructor, destructor, or type conversion before '<' token mesh.cpp:38: error: expected `;' before '<' token
where line 38 is highlighted in the following portion of code.
Could you help me to resolve this problem?
Thanks in advance, Giulio
template <class PredecessorMap> class record_predecessors : public dijkstra_visitor<> { public: record_predecessors(PredecessorMap p) : m_predecessor(p) { }
template
void edge_relaxed(Edge e, Graph& g) { // set the parent of the target(e) to source(e) put(m_predecessor, target(e, g), source(e, g)); } protected: PredecessorMap m_predecessor; }; template <class PredecessorMap> line 38: record_predecessors<PredecessorMap> make_predecessor_recorder(PredecessorMap p) { return record_predecessors<PredecessorMap>(p); }
___________________________________ Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi Jeremy, Thank you very much. I resolved the problem using the new version of Dijkstra's algorithm that includes a named parameter for recording predecessors. Now I've another problem and I've no idea how to resolve it. I'd like to extract all possible shortest path from a sorce to a destination... not only one path. Please, could you help me to resolve this problem? Thanks a lot in advance, Giulio Jeremy Siek ha scritto:
Hi Giulio,
Glad you're enjoying the BGL :)
Hmm, I don't see anything wrong... perhaps the error is even earlier in the source file, causing the compiler's parser to become very confused.
If you want more help you'll need to send us a complete program that we can compile. Also, you'll need to tell us the compiler and its version number.
Cheers, Jeremy
On Sep 14, 2005, at 11:01 AM, Giulio Veronesi wrote:
Hi all,
I'm enjoying learning the boost graph library. I'm trying to use the Dijkstra algorithm and try to store the shortest path as explained in the subsection "Extending Algorithms with Visitors" of the section "Quick Tour" of the BGL user guide.
When I try to compile my code, I get the following error message:
mesh.cpp:38: error: expected constructor, destructor, or type conversion before '<' token mesh.cpp:38: error: expected `;' before '<' token
where line 38 is highlighted in the following portion of code.
Could you help me to resolve this problem?
Thanks in advance, Giulio
template <class PredecessorMap> class record_predecessors : public dijkstra_visitor<> { public: record_predecessors(PredecessorMap p) : m_predecessor(p) { }
template
void edge_relaxed(Edge e, Graph& g) { // set the parent of the target(e) to source(e) put(m_predecessor, target(e, g), source(e, g)); } protected: PredecessorMap m_predecessor; }; template <class PredecessorMap> line 38: record_predecessors<PredecessorMap> make_predecessor_recorder(PredecessorMap p) { return record_predecessors<PredecessorMap>(p); }
___________________________________ Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi all,
I'm enjoying learning the boost graph library. I'm trying to use the Dijkstra algorithm and try to store the shortest path as explained in the subsection "Extending Algorithms with Visitors" of the section "Quick Tour" of the BGL user guide.
When I try to compile my code, I get the following error message:
mesh.cpp:38: error: expected constructor, destructor, or type conversion before '<' token mesh.cpp:38: error: expected `;' before '<' token --------->8---------------->8----------------->8------ template <class PredecessorMap> line 38: record_predecessors<PredecessorMap> make_predecessor_recorder(PredecessorMap p) { return record_predecessors<PredecessorMap>(p); } ___________________________________ Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it You forgot 'struct' or 'class' at the start of line 38 :D. I find it hard to be too amused, since I have done exactly
Giulio Veronesi wrote: the same thing quite a lot.

Simon Buchan wrote:
Giulio Veronesi wrote:
Hi all,
I'm enjoying learning the boost graph library. I'm trying to use the Dijkstra algorithm and try to store the shortest path as explained in the subsection "Extending Algorithms with Visitors" of the section "Quick Tour" of the BGL user guide.
When I try to compile my code, I get the following error message:
mesh.cpp:38: error: expected constructor, destructor, or type conversion before '<' token mesh.cpp:38: error: expected `;' before '<' token
--------->8---------------->8----------------->8------
template <class PredecessorMap> line 38: record_predecessors<PredecessorMap> make_predecessor_recorder(PredecessorMap p) { return record_predecessors<PredecessorMap>(p); } ___________________________________ Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it
You forgot 'struct' or 'class' at the start of line 38 :D. I find it hard to be too amused, since I have done exactly the same thing quite a lot. Duh!! ignore last message. I'm stupider than even _I_ thought! (Must have just been looking at mpl stuff or something?)
participants (3)
-
Giulio Veronesi
-
Jeremy Siek
-
Simon Buchan