Re: anonymous functions (lambdas)

From: George Huber (kharmon_at_optonline.net)
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
want.

George



Relevant Pages

  • Re: anonymous functions (lambdas)
    ... > I have a function which takes as an argument a pointer to another ... I'm not sure about lambda calculus but please could you try to explain ... Invoke foo ON an anonymous function. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: anonymous functions (lambdas)
    ... > Is there any way to invoke foo on an anonymous function, i.e., a ... support for functional programming. ... Alwyn ...
    (alt.comp.lang.learn.c-cpp)
  • Re: anonymous functions (lambdas)
    ... In article, Gianni Mariani ... >Mark P wrote: ... >> I have a function which takes as an argument a pointer to another ... >> Is there any way to invoke foo on an anonymous function, i.e., a ...
    (alt.comp.lang.learn.c-cpp)
  • Re: anonymous functions (lambdas)
    ... Mark P wrote: ... > I have a function which takes as an argument a pointer to another ... > Is there any way to invoke foo on an anonymous function, i.e., a ... You could possibly create a macro that could emulate this in C++. ...
    (alt.comp.lang.learn.c-cpp)