boost::shared_ptr and stl algorithms
std::vector< boost::shared_ptr<T> > TVec; I want to write a function object to run std::for_each. to do somework against members of T and accumulate results in functor. My attempts have failed in VC7 with memory errors in my operator() method. struct fo { bool operator()( boost::shared_ptr<T>& t ) { return true; } }; Thanks in advance bille
From: "Bill Eidson"
std::vector< boost::shared_ptr<T> > TVec;
I want to write a function object to run std::for_each. to do somework against members of T and accumulate results in functor. My attempts have failed in VC7 with memory errors in my operator() method.
struct fo { bool operator()( boost::shared_ptr<T>& t ) { return true; } };
Can you post a complete program that shows the problem? I see nothing wrong with the snippets above. Perhaps you try to call a member via an empty shared_ptr?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, can someone give an example how to "not use the built-in vertex index, and instead use a property to add my own vertex index property" (see page 223 BGL-book) for an adjacency_list? My problem is that I'm using the vecS selector for the VertexList template parameter and I need to remove vertices from my graph (but not frequently). Every time I do this, my vertex descriptors are invalidated (as described in the book). I need a solution so that I can remove some vertices and all my vertex descriptors remain valid. Thanks in advance, Michael - -- http://www.ive.uni-hannover.de # kettner@ive.uni-hannover.de -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9LulmkCdGnb0kVFMRAjFOAJ9EPNIOLP+vWqEJLpgzFi2pBij6MgCdFSN8 pOc9vhZRn8gAnc3JSTWJW2I= =APLS -----END PGP SIGNATURE-----
Hi Michael, You can't add your own vertex_index property to an adjacency_list with VertexList=vecS. The adjacency_list will just ignore it if you do. You can if VertexList=listS, and example/adjacency_list.cpp is an example of this. Also, you can add properties with names other than vertex_index_t to adjacency_list with VertexList=vecS. For example, you could add your own vertex_id_t property. However, this would *not* keep the vertex descriptors from being invalidated, it would just give you a vertex_id_t property that is stable. I'm not sure if the above helps... I don't know the details of what you are trying to do, but feel free to ask further questions. Cheers, Jeremy On Fri, 12 Jul 2002, Michael Kettner wrote: kettne> Hi, kettne> kettne> can someone give an example how to "not use the built-in vertex index, and kettne> instead use a property to add my own vertex index property" (see page 223 kettne> BGL-book) for an adjacency_list? kettne> My problem is that I'm using the vecS selector for the VertexList template kettne> parameter and I need to remove vertices from my graph (but not frequently). kettne> Every time I do this, my vertex descriptors are invalidated (as described in kettne> the book). I need a solution so that I can remove some vertices and all my kettne> vertex descriptors remain valid. kettne> kettne> Thanks in advance, kettne> kettne> Michael ---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Jeremy,
thanks for your quick reply.
What I do is the following: I wrote my own class representing nodes (class
myNodeClass). Now I'm creating nodes in a graph, mapping each resulting
vertex index to the associated myNode-object in a std::map. I hope the
following code fragment is enough to give you an idea:
class myNodeClass;
typedef boost::adjacency_list
Hi Michael,
You can't add your own vertex_index property to an adjacency_list with VertexList=vecS. The adjacency_list will just ignore it if you do. You can if VertexList=listS, and example/adjacency_list.cpp is an example of this.
Also, you can add properties with names other than vertex_index_t to adjacency_list with VertexList=vecS. For example, you could add your own vertex_id_t property. However, this would *not* keep the vertex descriptors from being invalidated, it would just give you a vertex_id_t property that is stable.
I'm not sure if the above helps... I don't know the details of what you are trying to do, but feel free to ask further questions.
Cheers, Jeremy
On Fri, 12 Jul 2002, Michael Kettner wrote: kettne> Hi, kettne> kettne> can someone give an example how to "not use the built-in vertex index, and kettne> instead use a property to add my own vertex index property" (see page 223 kettne> BGL-book) for an adjacency_list? kettne> My problem is that I'm using the vecS selector for the VertexList template kettne> parameter and I need to remove vertices from my graph (but not frequently). kettne> Every time I do this, my vertex descriptors are invalidated (as described in kettne> the book). I need a solution so that I can remove some vertices and all my kettne> vertex descriptors remain valid. kettne> kettne> Thanks in advance, kettne> kettne> Michael -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org
iD8DBQE9LxOVkCdGnb0kVFMRAsIjAJ9CJGpmbc6lpuoEhGgeznxdUunndwCfRnh4 wbjiVESZ3HwVrNkhJ4Gvf48= =0S8n -----END PGP SIGNATURE-----
Hi Michael,
On Fri, 12 Jul 2002, Michael Kettner wrote:
kettne> Hi Jeremy,
kettne>
kettne> thanks for your quick reply.
kettne> What I do is the following: I wrote my own class representing nodes (class
kettne> myNodeClass). Now I'm creating nodes in a graph, mapping each resulting
kettne> vertex index to the associated myNode-object in a std::map. I hope the
kettne> following code fragment is enough to give you an idea:
kettne>
That's a tough one. The easiest solution I see is switching to
VertexList=listS. Do you have a reason for prefering vecS?
This issue has me thinking... I see a way to change
adjacency_list
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Jeremy, On Friday 12 July 2002 20:17, Jeremy Siek wrote:
Yeah, dijkstra_shortest_paths requires a vertex_index property map, which is by default obtained from the graph. You need to add vertex_index_t as a internal vertex property for your graph and initialize it with appropriate integers.
Must the integers I provide be in the range [0,|V|)?
My code still fails to compile, the error messages i get are always like:
/boost/graph/dijkstra_shortest_paths.hpp:199:
passing `void *' to argument 2 of `put
Hi Michael, On Sun, 14 Jul 2002, Michael Kettner wrote: kettne> To give me (and all the others having the same problem) a hint: Could you kettne> please explain how to change the "dijkstra-example.cpp" from boost_1_28_0 to kettne> compile with "listS" as VertexIndex template? I've written up a new example, dijkstra-example-listS.cpp which uses listS as the VertexList parameter for the graph. The file is checked into boost CVS in the example directory. Cheers, Jeremy ---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Jeremy, thanks for providing the example. I didn't get the time to apply it to my graph as yet, but I will let you know if there should be problems doing so. Thanks so far for the great support! Michael
I've written up a new example, dijkstra-example-listS.cpp which uses listS as the VertexList parameter for the graph. The file is checked into boost CVS in the example directory.
- -- http://www.ive.uni-hannover.de # kettner@ive.uni-hannover.de -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9RjU6kCdGnb0kVFMRAirOAJ0cLOw7SDsuoh41gkKeiVpXrudvlgCcC+Ww bJaP7YOTvrSowP3VbnKMLyg= =FB4H -----END PGP SIGNATURE-----
Hi, Jeremy, In your email, you mentioned dijkstra has problems with listS vertices and you gave an example. I found the incremental_components.cpp has the same problem with listS vertices. Is it right? Do you have an listS example for incremental_compoents too? Or it is the problem of MSVC 6.0 again? Thanks! Vivid Jeremy Siek wrote:
Hi Michael,
On Sun, 14 Jul 2002, Michael Kettner wrote: kettne> To give me (and all the others having the same problem) a hint: Could you kettne> please explain how to change the "dijkstra-example.cpp" from boost_1_28_0 to kettne> compile with "listS" as VertexIndex template?
I've written up a new example, dijkstra-example-listS.cpp which uses listS as the VertexList parameter for the graph. The file is checked into boost CVS in the example directory.
Cheers, Jeremy
---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
participants (5)
-
Bill Eidson
-
Jeremy Siek
-
Michael Kettner
-
Peter Dimov
-
Vivid Yang