|
Boost Users : |
Subject: Re: [Boost-users] Bind questions
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-06-07 14:57:03
AMDG
John Dlugosz wrote:
> Ah yes, I remember reading that extra parameters called are simply ignored, and the rationale that this is generally good for callbacks.
>
> And, you clarify that the extra arguments are dropped, as opposed to filling in extra args for the binded target. I was wondering if you could pass the "incoming" signature separate from having it deduced from the first argument to bind.
I'm not quite sure what you mean. Bind doesn't care about the
signature of the first argument. It just tries to call it with whatever
arguments it's given. The type checking happens then.
> As it exists now, "bind" supplies all arguments to the bound call, some of which may be placeholders. You don't leave off trailing placeholders. Right? There is no "bind first n" function.
> Now your example shows extra arguments ignored when calling the function object returned by bind, but the desired type was never given.
>
> function<void (int,int,int,int)> callback;
> callback= bind...
>
> Will that, in general, adapt the result of bind when assigned? More to the point, what is the purpose of the signature in the function object, if the function's operator() takes anything and throws away extras, besides? I'm basically lost when it comes to what is typed, where, and when.
>
function<void(int, int, int, int)> stores any function object that can
be called with four ints. The function object returned by bind()
is called with those arguments, and may ignore some of them.
The signature is necessary for boost::function, because boost::function
is monomorphic. The bind function objects are polymorphic and
try to adapt to whatever is thrown at them.
In Christ,
Steven Watanabe
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