Bug? lambda+function composition not working together
Operator , (nullary composition) does not seem work between
boost::function and boost::lambda.
Is this a bug? Is there any way to work around this?
void foo() { std::cout << "foo"; }
boost::function
On Oct 5, 2006, at 8:12 AM, Johan Torp wrote:
Operator , (nullary composition) does not seem work between boost::function and boost::lambda. Is this a bug? Is there any way to work around this?
void foo() { std::cout << "foo"; }
boost::function
f(boost::lambda::bind(&foo)); (f,f)(); // Outputs foo
Okay, so here we're getting the built-in ',' operator, and "f, f" has no effect other than to give "f" back.
(boost::lambda::bind(&foo),f)(); // Outputs foo
Doesn't this say: "call foo(), then return f as a value" ?
(f,boost::lambda::bind(&foo))(); // Outputs foo
Again, I think we're getting the built-in ',' operator, and the "f" at the beginning has no effect. If the "f" were instead "boost::lambda::bind(f)", then it should do as you expect.
(boost::lambda::bind(&foo), boost::lambda::bind(&foo))(); // Outputs foofoo
This is definitely what I'd expect. Should the ',' operator in the Lambda library work for all function objects, or just lambda's function objects? I'm not really sure, but we can't detect "all" function objects safely. We could patch up "," to also work with boost::function, but I'm not sure if that's the way to go. In other words, I really can't tell if this is a bug or a feature :) Doug
participants (2)
-
Doug Gregor
-
Johan Torp