[graph] adjacency_list::operator=()

Hello all, If I have an adjacency_list g and I call g = g; all of the vertices and edges of g are removed. This is not what I would expect; I would expect that this operation would not change g. 1. Is this the desired behavior? (It seems different than what other types do.) 2. Is this issue old news? (I couldn't find it on the mailing list archives but it may well be there.) Thanks, David

--- "David M. Jones" <djones@keymark.com> wrote:
Hello all,
Hello, David.
If I have an adjacency_list g and I call g = g; all of the vertices and edges of g are removed. This is not what I would expect; I would expect that this operation would not change g.
Oooh, aliasing...
1. Is this the desired behavior? (It seems different than what other types do.)
Looking at <boost/graph/detail/adjacency_list.hpp>, I see that the member operator=, before copying, clears its owner of its vertices and edges without first checking if *this != g. (Basic question: is such checking possible? I tried a couple of times without success.) This is true for both subclasses of detail::adj_list_helper. Not sure if it's desired, though.
2. Is this issue old news? (I couldn't find it on the mailing list archives but it may well be there.)
I'm curious as to where one would use g = g. Cromwell Enage __________________________________ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo

On Wed, 20 Oct 2004 19:01:22 -0700 (PDT), Cromwell Enage <sponage@yahoo.com> wrote:
...without first checking if *this != g (Basic question: is such checking possible? I tried a couple of times without success.) Without having any idea of boost::graph, can you check for identity? (this!=&g)?
Cheers, Michael

"Cromwell Enage" <sponage@yahoo.com> wrote:
I'm curious as to where one would use g = g.
I have written a helper class that holds a reference to a boost::adjacency_list object. When writing the assignment operator for that class, I (apparently naively) called this.m_g = other.m_g; In this case, my helper class should hold a pointer rather than a reference. That way I can copy an address rather than copying an object, which is what I really want anyway. I guess this is a rather long-winded way of saying: I don't know of a situation where one would use g = g. Thanks for your reply, David

On Oct 20, 2004, at 12:06 PM, David M. Jones wrote:
Hello all,
If I have an adjacency_list g and I call g = g; all of the vertices and edges of g are removed. This is not what I would expect; I would expect that this operation would not change g.
1. Is this the desired behavior? (It seems different than what other types do.) 2. Is this issue old news? (I couldn't find it on the mailing list archives but it may well be there.)
Oops, thanks for reporting this. It's fixed now. Doug
participants (4)
-
Cromwell Enage
-
David M. Jones
-
Doug Gregor
-
Michael Walter