Code::Blocks not recognizing operators

So I have this code in Code::Blocks:

vector<int>puzzleBox;

... (bunch of code, assigning places in vector to integers)

int b;

while( b != puzzleBox.end())
{
(bunch of more code)
}


The problem appears to be in the while statement, Code::Blocks says:

error: no match for 'operator!=' in 'b != puzzleBox.std::vector<_Tp, _Alloc>::end [with _Tp = int, _Alloc = std::allocator<int>]().__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator+ [with _Iterator = int*, _Container = std::vector<int, std::allocator<int> >](((const ptrdiff_t&)((const ptrdiff_t*)(&1))))'|

From what I can tell, Code::Blocks is not recognizing the != operator. Can someone please tell me what the problem is?
You are trying to compare an integer (b) with an iterator (puzzleBox.end()). This is not an error with Code::Blocks (its just an IDE), instead its an error with your code. Try doing this instead:
1
2
3
4
5
6
7
8
std::vector<int> puzzleBox;

// Assign Values

std::vector<int>::iterator it;
while (it != puzzleBox.end()) {
    // Do Something
}
That solved my problem, thank you!
Topic archived. No new replies allowed.