Christoph Bartoschek Guest
|
Posted: Thu Nov 16, 2006 11:51 pm Post subject: Calling a template operator with implicit conversion |
|
|
Hi,
I have a handle class that wraps pointer handles. Now I want to compare it
to the 0 pointer but the compiler does not find the operator==. Here is a
stripped down example:
#include <iostream>
class A {
};
template <typename T> class B {
};
bool operator==(A const & lhs, A const & rhs) {
return true;
}
template <typename T, typename U>
bool operator==(B<T> const & lhs, U * rhs) {
return false;
}
int main() {
B<int> b;
std::cout << (b == 0) << std::endl;
}
Is it somehow possible to let the call (b == 0) succeed?
I think the problem has its cause in a missing 0 pointer literal in C++. Is
such a literal added in the next standard?
Greetings
Christoph
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ] |
|