c++ - is there any member named std vector iterator operator ==? -


i can't compile this:

//cygwin g++ 4.9.2 std::vector<int> v; std::vector<int>::iterator i; i.operator==(v.begin()); //error: ...has no member named 'operator==' 

someone please let me know going on.

and why did assume, such member function exists? comparison operators don't have member functions.

it can defined global function well:

template <class t> bool operator(typename vector<t>::iterator left, typename vector<t>::iterator right) {     //... } 

in case, may not work:

i.operator==(v.begin()); 

while work:

i == v.begin(); 

also, if really want use such unnatural syntax, can call way:

operator==(i, v.begin()); 

but note, result quite unpredictable, don't initialize i.


Popular posts from this blog