Skip to main content
GameDev.net gamedev.net
🔒 Locked

boost::function comparison ?

Started by Impz0r Aug 14, 2006 at 9:08 AM 1 replies 1.9k views
Original Post
Impz0r
Impz0r
Heya, i'm a little confused right now. I'm using the boost::function templates quite a bit and today i came across a litle problem. What i'm trying to do is, compare two boost::function objects but this dosen't quite work. Even if both functors are of the same type, like:

typedef boost::function<void (void * ptr)> myFunctor;

myFunctor mf1;
myFunctor mf2;

// does not work, the compiler error is:
// error C2666: 'operator ==' : 4 overloads have similar conversions
if (mf1 == mf2) 
 
 {
  // do something awesome ...
 }


I guess i'm missing something ... any hints ? Thanks in advance. Impz0r
Stay Evil & Ugly!
Sharlin
Sharlin
Unfortunately, that is not possible. Please read this for a rationale.
Impz0r
Impz0r
Thanks Sharlin for your answer!

Hmm to bad that this is not working. Anyway, i need to find out if one funtor is equal to another. I looked through the boost::function header and found the function::contains() method. May i use these to compare two functors if there function pointer is equal ?


[EDIT]
I've got it to work with a little workaround, which means i encapsulate the boost::function within a tiny class and compare the instance pointers. ;)




Impz0r

[Edited by - Impz0r on August 15, 2006 6:12:35 AM]
Stay Evil & Ugly!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.