vector of lists: anyone know how to do this?

L

loufoque

Kirit Sælensminde wrote :
Prefer something like this:

boost::shared_ptr< Edge > pEdge;

You shouldn't use boost::shared_ptr for that. Actually I still wonder
why you should ever use it.

If you really want a container of pointers (because of polymorphism),
then use boost pointer containers.
Otherwise just use a container of Edge, not of Edge*.
 
L

loufoque

- Each edge object might take lots of memory and if the graph is big,
you might end up using lot of memory

If he wanted to make a graph he should just use boost.graph.
 
?

=?iso-8859-1?q?Kirit_S=E6lensminde?=

loufoque said:
Kirit Sælensminde wrote :


You shouldn't use boost::shared_ptr for that. Actually I still wonder
why you should ever use it.

If you really want a container of pointers (because of polymorphism),
then use boost pointer containers.
Otherwise just use a container of Edge, not of Edge*.

Without knowing more about the context it is of course hard to know
which smart pointer to use. An edge normally would have no pointers
back out (BOCTOE) so there should be no chance of circular dependancies
making boost::shared_ptr a reasonable choice. I did say that it was
_often_ a good choice, not that it was _always_ a good choice.

Is there a better general purpose smart pointer around? (This is a
genuine question)


K
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,232
Latest member
DorotheaDo

Latest Threads

Top