Re: anonymous functions (lambdas)

From: George Huber (
Date: 10/14/04

Date: Thu, 14 Oct 2004 03:15:19 GMT

On Wed, 13 Oct 2004 17:50:59 -0700, Mark P wrote:

> I have a function which takes as an argument a pointer to another
> function. Say,
> foo(int (*bar)(int x))
> Is there any way to invoke foo on an anonymous function, i.e., a
> function which is defined only as an argument to foo. I'm thinking
> something like:
> foo( {int lambda(int x) {return x*x;}} );
> Hopefully my intent here is clear enough that someone can tell me the
> proper way to formulate such a statement if such a thing is even possible.
> Thanks,
> Mark

Take a look at the boost lambda library. I think this will do what you