vendredi 21 août 2015

How to merge two containers (vectors/lists) of different structs, but with one common parameter in C++

Using C++ with boost/stl, how can I merge two lists of different objects, say, A and B? They have some common and some different fields/properties and do not share unique id.

class A
{
   int id;
   double smth;
}

class B
{
   int id;
   std::string name;
   Type type;
}

class C
{
   int id;
   std::string name;
   Type type;
   double smth;
}

So idea is that I have e.g. std::list<A> and std::list<B> and I want to easily merge them to std::list<C>

Aucun commentaire:

Enregistrer un commentaire