How do I copy all elements of a vector which is a struct of elements, to a set.
struct info
{
std::string code;
std::string curDate;
int iVar;
};
std::vector<info> infVect; // Load data into the vector from the database
std::set<std::string> uniqueCodes;
for ( int i = 0; i < infVect.size() ; ++i)
uniqueCodes.insert(infVect[i].code);
Is there a faster way to store the elements from vector to set without iterating each element in the loop?
Note:
std::set<std::string> uniqueCodes(infVect.begin(), infVect.end() )
, would work if infVect
had only code. But infVect
is a vector of objects.