mercredi 29 mars 2017

Is the object a vector?

I am using a template typename recursive function. I would like at some point to ask if the object I am manipulating is a vector (a vector of anything). Something like the is_vector function below

template <typename TYPE>
void f(const std::vector<TYPE>& x)
{
   for (auto& element : x)
   {
      if (is_vector(element))
      {
         f(element);
      } else
      {
         g(element);
      }
   }
}

Is this feasible?

Aucun commentaire:

Enregistrer un commentaire