"John Harrison" <jo*************@hotmail.com> wrote in message
news:2v*************@uni-berlin.de...
"Jason Heyes" <ja********@optusnet.com.au> wrote in message
news:41***********************@news.optusnet.com.a u...I want to assign one std::set object to another without worrying about
performance. Do implementations std::set use data sharing? Thanks.
No they don't. Use a smart pointer.
Agreed.
A sometimes valid alternative is to use the swap() member
function of std::set (or any other container):
set1.swap( set2 );
This is guaranteed to be efficiently implemented, and might allow
you to do what you want.
For example, a common C++ idiom to avoid unnecessary copies
when adding items to a container is to replace:
myQueueOfSets.push_back( aNewSet )
with:
myQueueOfSets.push_back( std::set<ItemType>() ); // add empty set
myQueueOfSets.back().swap( aNewSet );
hth-Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <>
http://www.brainbench.com