Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

compare two boost::function

Tags:

c++

boost

void ff(int){} 

void Unscribe(const boost::function<void(int)>& f)
{
    std::map<int, boost::function<void(int)> > map;

    map[0] = ff;

    if( map[0] == f)
    {

    }  
}

Unscribe( ff ); 

I would like to be able to compare two boost::function with the same signature. What should I modified to get this code compilable ?

like image 885
Guillaume Paris Avatar asked Aug 30 '11 14:08

Guillaume Paris


1 Answers

You can't. Read the boost function FAQ's first entry:

  1. Why can't I compare boost::function objects with operator== or operator!=?

Comparison between boost::function objects cannot be implemented "well", and therefore will not be implemented. ...

like image 194
Armen Tsirunyan Avatar answered Oct 23 '22 21:10

Armen Tsirunyan