Boost logo

Boost Users :

Subject: [Boost-users] [Function] Overloaded functor as a boost::function
From: Alexander Lamaison (awl03_at_[hidden])
Date: 2010-02-13 20:11:21


I'm trying to pass a function with an overloaded operator() to a function
expecting a boost::function parameter. This fails to compile as it appears
to pick the wrong overload.

Here is the functor interface with the two ways it can be called:

class Command
{
public:
        virtual void operator()(
                const com_ptr<IShellItemArray>& items,
                const com_ptr<IBindCtx>& bind_ctx);

        virtual void operator()(
                const com_ptr<IDataObject>& data_object,
                const com_ptr<IBindCtx>& bind_ctx);
};

When I try to pass an instance of this functor to a method expecting a
boost::function of this type:
boost::function<void(
                const com_ptr<IShellItemArray>& items,
                const com_ptr<IBindCtx>& bind_ctx)>
I get a compiler error C2440: '=' : cannot convert from 'IShellItemArray *'
to 'IDataObject *'. This seems to indicate that the boost::function is
trying to pass its parameters to the second overload rather than the first.

Any ideas how I can make boost::function pick the correct overload? I'm
using Boost 1.40.0.

Many thanks.

Alex Lamaison

--
http://swish.sourceforge.net

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net