|
Boost Users : |
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2007-08-10 03:44:41
Stefano Peluchetti <pelux <at> ngi.it> writes:
> I'm actually moving everything to
> boost::lambda::bind to
> 1) avoid the conflict of boost::lambda::_1 and _1
> 2) have binders that are "lambda ready" if needed
>
> Thank you in advance for your reply.
Note that sometimes boost::bind is a better choice
that boost::lambda::bind.
1. boost::bind has better support for smart pointers.
struct A
{
void f() {}
};
shared_ptr<A> a;
bind(&A::f, _1)(a); // works for boost::bind only
2. boost::bind sometimes can choose correct instance of
overloaded function. (probably you got hit by this distinction).
struct A
{
void f() const {}
void f() {}
};
A a;
bind(&A::f, a); // works for boost::bind only
3. boost::bind can accept non-const rvalue if there
are not many arguments. I believe last (unreleased)
version of boost::lambda::bind can do this as well.
void f(int) {}
bind(f, _1)(42); // works for boost::bind only
My personal experience also shows that boost::bind
based code compiles faster.
Roman Perepelitsa.
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