I intend to define a custom operator==
for boost::tuple
#include <iostream>
#include <vector>
#include <boost/tuple/tuple.hpp>
//#include <boost/tuple/tuple_comparison.hpp>
/*namespace boost { namespace tuples {*/
bool operator==(const boost::tuple<int>&, const boost::tuple<int>&){
return false;
}
/*}}*/
int main(){
boost::tuple<int> t, u;
std::vector<boost::tuple<int> > vec;
std::cout << (t == u); // [1]
find(vec.begin(), vec.end(), t); // [2]
}
While this works for [1], it fails for [2] with the following error:
/usr/local/include/c++/4.9.2/bits/predefined_ops.h:191:17: error:
no match for 'operator==' (operand types are 'boost::tuples::tuple<int>'
and 'const boost::tuples::tuple<int>')
{ return *__it == _M_value; }
So, my question is, why does the compiler not look for operator==
in the global namespace in the case of std::find
.
NB: it works if i place the operator==
in namespace boost::tuples
as shown in the comments above.