I am writing a template class function by comparing std :: strings. std :: string - template parameter. My problem is that I cannot compare two constant strings with the "==" operator, then I think that I am creating two non-constant temporary string variables to perform the comparison, but it still cannot compile. I do not know why.
the VGraph class is defined as VGraph<std::string, std::string> myGraph;
template <typename V, typename E> size_t VGraph<V, E>::find(const V& vert) { V temp = vert; // (1) for (size_t i=0; i<graph.size(); i++) { V noneConst = graph[i].getVertex(); // (2) if (temp==noneConst)// I think broblem is here, and tried to fix using (1)(2) return i; } return graph.size(); }
Prototype related function
template <typename V, typename E> const V& VVertex<V, E>::getVertex();
source share