T
Thomas
I have a question about how the stl map class works. I have a subscription
class that I use to manage client application subscriptions. These are
stored in a map. Periodically, I need to update the subscriptions in the map
to reflect changes to data. When I iterate over the map, I expect to get a
reference to the object stored in the map using
myclass mc = *iter->second;
What I am finding is that the copy constructor is getting invoked resulting
in a copy getting returned instead of a reference.
I tried the alternate approach using the operator[] but get the same
results.
At this point the workaround is to put the modified object back into the map
which seems terribly inefficient.
I checked the SGI website and it looks like it should be returning a
reference and not a copy. But I am not certain.
This is on Solaris 2.8 with 6.2 compiler.
Does this sound correct? Should I expect this to be the defined behavior or
am I missing something?
Thanks,
Thomas
class that I use to manage client application subscriptions. These are
stored in a map. Periodically, I need to update the subscriptions in the map
to reflect changes to data. When I iterate over the map, I expect to get a
reference to the object stored in the map using
myclass mc = *iter->second;
What I am finding is that the copy constructor is getting invoked resulting
in a copy getting returned instead of a reference.
I tried the alternate approach using the operator[] but get the same
results.
At this point the workaround is to put the modified object back into the map
which seems terribly inefficient.
I checked the SGI website and it looks like it should be returning a
reference and not a copy. But I am not certain.
This is on Solaris 2.8 with 6.2 compiler.
Does this sound correct? Should I expect this to be the defined behavior or
am I missing something?
Thanks,
Thomas