Boost logo

Boost :

Subject: Re: [boost] [local_function] any interest in a LocalFunction library?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2010-08-23 10:05:32


On 23/08/10 13:43, Dmitry Goncharov wrote:

> What's wrong with the following?
> Aside from the know limitations. (local::f cannot be a template arg or be a function template).
> void f()
> {
> struct local
> {
> static void f() {}
> };
> local::f();
> }
>
> Does your library have advantages over this?

I believe his macro has mechanisms for catching some variables in scope
(at least, ScopeExit had).

Something you would do with

struct local
{
     local(int j_) : j(j_) {}

     int operator()(int i)
     {
         return i + j;
     }

private:
     int j;
};
local f(j);

could be written as something like

LOCAL_FUNCTION_BEGIN(f, (j), (int i))
{
    return i + j;
}
LOCAL_FUNCTION_END

Surely you would agree the second form is quite more succint


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk