vec
is std::vector<std::string>
type. I'm trying to remove strings which not equal to query
.
Compare compare(0, i, query); vec.erase(std::remove(vec.begin(), vec.end(), compare));
This is my Functor:
class Compare { private: size_t m_from; size_t m_to; std::string m_query; public: Compare(size_t from, size_t to, std::string& query) : m_from(from), m_to(to), m_query(query) {} std::string operator()(std::string s) { if(s.substr(m_from, m_to) != m_query.substr(m_from, m_to)) { return s; } } };
I get this compile error:
error: no match for ‘operator==’ (operand types are ‘std::__cxx11::basic_string<char>’ and ‘const Compare’)
241 | { return *__it == _M_value; }
I understand that I'm missing operator==
, but why and where?
Thanks!