I have two boost intrusive sets which I need to merge it together. I have map_old.m_old_attributes boost intrusive set which I need to merge it to m_map_new_attributes boost intrusive set
void DataTest::merge_set(DataMap& map_old)
{
// merge map_old.m_old_attributes set into m_map_new_attributes
}
What is the best way to do this? I am not able to find a function which can do the merge for me? I recently started working with boost intrusive sets and I am not able to find predefined methods which can do the merge, or may be I am wrong?
Indeed intrusive sets are a different beast. They don't manage their element allocations.
So when merging you need to decide what that means. I'd say a reasonable interpretation would be that you want to move the elements contained inside the
map_oldcontainer into the DataMap.This would leave
map_oldempty. Here's such an algorithm:See it Live On Coliru
Of course you can come up with different semantics for the merge operation (which would be more akin to 'copy' instead of 'move')