lundi 19 novembre 2018

define a method with a vector of templates as an argument

I have a method in my C++11 code that accepts a template as an argument

template<typename type> uint64_t insert(type item) {
    //code
    return id; 
 }

and I want to create a similar in order to insert many items. My attempt was to pass these items as a vector. However the compilation failed with error "error: template argument 1 is invalid"

template<typename type> std::vector<uint64_t> insert_many(std::vector<type insta> items) {

   std::vector<uint64_t> v;
  //v.push_back(...)
  //code
  return v; 
}

What is wrong with the above method signature?

Aucun commentaire:

Enregistrer un commentaire