The problem along with workarounds is described in the FAQ section of Boost.Bind .
You can also use utility functions, such as:
#include <boost/bind.hpp>
#include <boost/optional.hpp>
template <class Ret, class Obj>
Ret (Obj::* const_getter(Ret (Obj::*p) () const)) () const
{
return p;
}
template <class Ret, class Obj>
Ret (Obj::* nonconst_getter(Ret (Obj::*p)())) ()
{
return p;
}
int main()
{
boost::bind( const_getter(&boost::optional<int>::get), _1 );
boost::bind( nonconst_getter(&boost::optional<int>::get), _1 );
}
source
share