J
Jim West
Can someone explain to me why the following fails to compile:
#include <map>
namespace LOCAL {
class INDX {
public:
int x, y, z;
};
}
inline bool operator<(const LOCAL::INDX& a, const LOCAL::INDX& b);
typedef std::map<LOCAL::INDX, double> MY_MAP;
int main() {
MY_MAP my_map;
LOCAL::INDX idx, idx1;
MY_MAP::iterator pos = my_map.find(idx);
}
The Intel i386 Linux compiler gives me
/opt/intel/compiler81/include/c++/functional(134): error: no operator
"<" matches these operands
operand types are: const LOCAL::INDX < const LOCAL::INDX
return (_Left < _Right);
^
The GNU G++ error is similar.
Through trial and error, I found that the error goes away if I put
the definition of the < operator into the LOCAL namespace, but I don't
understand why it matters.
#include <map>
namespace LOCAL {
class INDX {
public:
int x, y, z;
};
}
inline bool operator<(const LOCAL::INDX& a, const LOCAL::INDX& b);
typedef std::map<LOCAL::INDX, double> MY_MAP;
int main() {
MY_MAP my_map;
LOCAL::INDX idx, idx1;
MY_MAP::iterator pos = my_map.find(idx);
}
The Intel i386 Linux compiler gives me
/opt/intel/compiler81/include/c++/functional(134): error: no operator
"<" matches these operands
operand types are: const LOCAL::INDX < const LOCAL::INDX
return (_Left < _Right);
^
The GNU G++ error is similar.
Through trial and error, I found that the error goes away if I put
the definition of the < operator into the LOCAL namespace, but I don't
understand why it matters.