AMDG
Joel de Guzman wrote:
There is no way for result to distinguish between these cases,
even though they are different.
Out of curiosity, how does Boost.Bind and Lambda.Bind behave in this
regard?
It looks like:
a) bind always constifies the return type of a pointer to a data member.
b) lambda does not strip references in its return type deduction.
#include
#include
#include
#include
#include
struct x {
int m;
};
void boost_bind() {
using namespace boost;
x x_ = {0};
bind(&x::m, x_)();
bind(&x::m, ref(x_))() = 1; // does not compile--returns const int&
bind(&x::m, cref(x_))();
}
void boost_lambda() {
namespace lambda = boost::lambda;
x x_ = {0};
lambda::bind(&x::m, x_)();
lambda::bind(&x::m, lambda::var(x_))() = 1;
lambda::bind(&x::m, lambda::var(static_cast(x_)))();
}
void boost_phoenix() {
namespace phoenix = boost::phoenix;
x x_ = {0};
phoenix::bind(&x::m, phoenix::val(x_))(); // does not compile
phoenix::bind(&x::m, phoenix::ref(x_))() = 1;
phoenix::bind(&x::m, phoenix::cref(x_))(); // does not compile
}
In Christ,
Steven Watanabe