On Tue, Dec 1, 2009 at 10:38 AM, OvermindDL1 <[email protected]> wrote:
> On Tue, Dec 1, 2009 at 10:15 AM, hadass yaari <[email protected]> wrote:
>> hello,
>> I'm trying to use boost::bind to solve my problem. I did it like this:
>>
>> pb->clicked().connect(SLOT(
>>
>> this, (boost::bind<void>(&AddPersonAuto::bla,5))));
>
> Try this? I am not sure it will work considering the very weird way
> Wt handles the connect function (*WAY* too over-engineered).
> pb->clicked().connect(this, (boost::bind(&AddPersonAuto::bla,_1,5)));
>
> And I honestly have no clue why Wt uses that nasty, useless SLOT macro
> either, you *should* just be able to do this since connect just need a
> nullary function to call, who cares if it is a function pointer, a
> functor, or any callable, it should just simplify things and just take
> a Boost.Function, which can accept and use it all (and which it so
> happens that the under-the-scenes Boost.Signals happens to take, thus
> Wt is creating some Binds when it is not necessary (wasting time and
> memory), and just making things all around more difficult then just
> taking a simple TR1/Boost.Function).
> pb->clicked().connect(boost::bind(&AddPersonAuto::bla,this,5));
I really mean this too, for example, what if I want to do something like this:
pb->clicked().connect(let(_a=ref(theTest))[if_(_a>0)[bind(AddPersonAuto::bla,val(this),_a++),bind(AddPersonAuto::differentBla,this,_a),--ref(theTest)]]);
To PrettyPrint that from above:
pb->clicked().connect(
let(_a=ref(theTest))
[
if_(_a>0)
[
bind(AddPersonAuto::bla,val(this),_a++),
bind(AddPersonAuto::differentBla,this,_a),
--ref(theTest)
]
]
);
Which would be the same thing as this:
void AddPersonAuto::doAction(void)
{
int a = theTest;
if(theTest>0)
{
bla(a++);
differentBla(a);
--theTest;
}
}
pb->clicked().connect(SLOT(this, AddPersonAuto::doAction));
Which is of course a *lot* more wordy (and yes I know the example is
not the best designed, I am just showing some programming styles I
use, and yes, that is valid C++).
But I cannot do that because of the rather horrible way the
Wt::Signals class was designed, instead of being generic, it is broken
in the useful cases...
Yes, if you cannot tell, I have no clue why the connect function was
designed so, rather horribly, and yes it has been bugging me more and
more as time goes on...
On Tue, Dec 1, 2009 at 10:34 AM, Wim Dumon <[email protected]> wrote:
> SLOT is a macro that is defined as:
> #define SLOT(x, y) x, &y
> I guess in your case you should omit the SLOT macro.
I just found out, that will not help, because whoever designed the
connect method did the stupid thing of doing things like:
template<class T, class V>
boost::signals::connection connect(T *target, void (V::*method)());
template<class T, class V>
boost::signals::connection connect(T *target, void (V::*method)(A1));
template<class T, class V>
boost::signals::connection connect(T *target, void (V::*method)(A1, A2));
And overloading it for each possible amount of variables (up to a
limit, not that high of a limit either), rather then just making it
generic, as would be expected and much more useful (and not require
that blasted SLOT macro at all, horrible design that macro is).
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest