I have a map where I\'d like to perform a call on every data type object member function. I yet know how to do this on any sequence but, is it possible to do it on an associativ
Just an example:
template
class insertIntoVec
{
public:
insertIntoVec(std::vector& vec_in):m_vec(vec_in)
{}
void operator () (const std::pair& rhs)
{
m_vec.push_back(rhs.second);
}
private:
std::vector& m_vec;
};
int main()
{
std::map aMap;
aMap[1] = "test1";
aMap[2] = "test2";
aMap[3] = "test3";
aMap[4] = "test4";
std::vector aVec;
aVec.reserve(aMap.size());
std::for_each(aMap.begin(), aMap.end(),
insertIntoVec(aVec)
);
}