I have 2 std::multiset
multiset<myObject *,dfa_ptr_states_less> m1;
multiset<myObject *,dfa_ptr_states_less> m2;
where I defined in an other file (myObject.h ) the Comparison function
struct dfa_ptr_states_less
{
bool operator()(const myObject *l, const myObject *r) const
{
return ( l->get_num_states() < r->get_num_states() );
};
};
where get_num_states is a field of myObject class.
m2 is empty. m1 point to dynamics objects. I have to do a copy of m1 in m2,namely a shallow copy of pointers from m1 to m2.
for(auto &ptr : m1)
m2.insert(ptr);
Simple but my doubt is: The order of elements in m1 is preserved in m2? If not, how can I do? (For my purposes the order is very important)
UPDATE:
Maybe is it possible do:
m2=m1
?