usercow
usercow

Reputation: 67

binary '==' : no operator found error for vector C++

When I compile my C++ program in VS 2017 I get a compile error saying: binary'==':no operator found which takes a left-hand operand of type std::vector<int, std::allocator_Ty> (or there is no acceptable conversion). It is my first time working with 2 dimensional vectors, I am not sure about exactly if this could have been part of the cause. My code is below. Can anybody help find why this is happening?

#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int>> feeds;

void foo()
{
    find(feeds.begin(), feeds.end(), feeds[0][0]);
}

Upvotes: 1

Views: 342

Answers (1)

rsjaffe
rsjaffe

Reputation: 5730

You are attempting to compare an int to a vector.

The line feeds.erase(find(feeds.begin(), feeds.end(), feeds[l][k]));, has two vector iterators (feeds.begin() and feeds.end()) but feeds[l][k] refers to a specific vector position rather than a vector. feeds[l] refers to the vectors, and should be used instead.

But why do you need find when you already know which vector to erase (feeds[l]). I suggest you check your logic and go from there.

Upvotes: 3

Related Questions