Don't get me wrong: Boost is bind()
great.
But I really hate writing and reading code with it, and I gave up the hope that my colleagues will someday want / use it.
I get code like this:
btn.clicked.connect(bind(&BetBar::placeBet, this, bet_id));
animator.eachFrame.connect(bind(&Widget::move, buttons[bet_id]));
Which, although logical, is very far from what I would call good code.
To demonstrate ... in C ++ 1x, we get the following:
btn.clicked.connect([&](int bet_id){ placeBet(bet_id); })
animator.eachFrame.connect([&](Point newPos) { buttons[bet_id].move(newPos) })
And a good DSL might look something like this:
on(btn.clicked) placeBet(bet_id);
on(animator.eachFrame) buttons[bet_id].move(eachFrame::newPos);
How do you deal with binding in C ++? Do you just live with what is pushing you?
Iraimbilanja
source
share