|
Boost Users : |
From: Victor A. Wagner, Jr. (vawjr_at_[hidden])
Date: 2003-09-30 23:36:16
note the additions and comments
At Tuesday 2003-09-30 14:11, you wrote:
>First, thanks for the prompt reply.
>
>I was wondering about mem_fn also
>IMO updating the docs to reflect that would be quite useful.... I think I
>personal prefer mem_fn() for our application.
>
>At Tuesday 2003-09-30 13:47, you wrote:
>>On Tuesday 30 September 2003 04:12 pm, Victor A. Wagner, Jr. wrote:
>> > I've been over the documentation several times and I keep getting the
>> > feeling that I'm just missing something.
>> > I'd like to have some member functions (methods) as slots for some signals
>> > (a la QT). I suspect that there is some form of bind that I could
>> use, but
>> > it's certainly not obvious to me.
>>
>>Yep, bind can do it:
>>
>>struct X {
>> int foo(float, char);
void blah() const;
>>};
>>
>>signal<int (X*, float, char)> sig;
>>sig.connect(bind(&X::foo, _1, _2, _3));
X xt;
signal<void(X*)> sigx;
sigx.connect(bind(&X::blah, &xt));
/// the above is more in line with what QT does with it's connect
(i.e. binds it to an instance and method)
/// now only if there were some nifty syntactic sugar we could come up
with so we could:
sigx.connect(magicsugar(&xt.blah));
/// which would more clearly show the intent, IMO
>>// or
>>sig.connect(mem_fn(&X::foo));
>>
>>The _1 is the implicit object parameter ("this") that the member function
>>pointer is invoked with.
>>
>> Doug
btw, I sent you a bug report w/ msvc++7.1 and debug assertion (heap not
valid) when destructing a signal
>>_______________________________________________
>>Boost-users mailing list
>>Boost-users_at_[hidden]
>>http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>Victor A. Wagner Jr. http://rudbek.com
>The five most dangerous words in the English language:
> "There oughta be a law"
>_______________________________________________
>Boost-users mailing list
>Boost-users_at_[hidden]
>http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Victor A. Wagner Jr. http://rudbek.com
The five most dangerous words in the English language:
"There oughta be a law"
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