C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calling a template operator with implicit conversion

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Christoph Bartoschek
Guest





PostPosted: Thu Nov 16, 2006 11:51 pm    Post subject: Calling a template operator with implicit conversion Reply with quote



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! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.