The simplest solution would be to loop over Vec
, checking if the element is a double
, then push the double into a T2Vec
. This is a C++03 version:
for (std::vector<Var>::const_iterator it = Vec.begin(); it != Vec.end(); ++it)
{
if (it->which() == 1) T2Vec.push_back(boost::get<T2>(*it));
}
C++11 version:
for (const auto& v : Vec)
{
if (v.which() == 1) T2Vec.push_back(boost::get<T2>(v));
}