views:

136

answers:

1

The full error I'm getting is this:

error: ambiguous overload for ‘operator[]’ in ‘a[boost::_bi::storage4<A1, A2, A3,     
boost::arg<I> >::a4_ [with A1 = boost::_bi::value<MsgProxy*>, A2 = boost::arg<1>, A3 = 
boost::arg<2>, int I = 3]]’

It references line 116 of a class I have, which is the boost::bind call in this function:

// Dispatch a message onto all connected clients
void MsgProxy::dispatch_msg(t_ic_msg_shptr message) {
    deque<t_socket_shptr>::const_iterator iter = clientList_.begin();

    for(; iter != clientList_.end(); ++iter) {
        message->async_send(*iter,
                boost::bind(&MsgProxy::handle_dispatch, this, _1, _2, _3));
    }
}

For reference, the handle dispatch function looks like this:

// Called to handle result of saync_send command in dispatch_msg
void MsgProxy::handle_dispatch(t_ic_msg_shptr messsage, t_socket_shptr socket_ptr, 
                   const boost::system::error_code &error) {
    if (error) {
    RDEBUG("Error forwarding message onto clients -- %s",
           error.message().c_str());
    }
}

And finally the async_send function that's being called:

void async_send        (t_socket_shptr, t_icsend_callback);

Where t_icsend_callback is:

typedef boost::function<void (t_socket_shptr, const boost::system::error_code&)> 
                                                              t_icsend_callback;

Basically I've got a function (async_send) that takes a socket to send out a message on, as well as a callback (defined using boost::function) to report status to asynchronously. I'm trying to bind a member to that boost::function argument, but boost doesn't seem to like what I'm doing here. I've been up and down the boost::function and boost:bind documentation and it seems to me this should work... I even have a call that's almost identical a little further up that's not throwing an error... color me stumped.

+2  A: 

t_icsend_callback is a function taking 2 agruments.

boost::bind(&MsgProxy::handle_dispatch, this, _1, _2, _3)

returns a function that takes 3 arguments.

I think you want to say

   message->async_send(*iter,
            boost::bind(&MsgProxy::handle_dispatch, this, message, _1, _2));

(note "message" as first bounded argument).

Eugene
Oh son of a gun, I should have seen that. Thanks for your eagle eyes. Sorry it took me so long to reply, I hit my thumb on a table saw and had to detour by the ER.
gct