Re: GCC 4.7.2 overhead of auto lambda expression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9 May 2013 14:08, Michael Powell wrote:
> Hello,
>
> It's been a little while, but I seem to recall that static variables
> can be declared in the scope of a class instance method?

Yes.

> Next question, I am declaring a lambda function in the scope of a
> method to leverage a read-from-channel-to-variable pattern: the read
> is the same, agnostic to the channel and variable.
>
> I am finding that this is somewhat slow, so a couple of thoughts are:
> is the lambda even appropriate? I declare it as an auto for starters,
> and it resolves every time the function happens.

I'm not sure what you mean.  Declaring a lambda expression is a
compile-time construct, so is 'auto', so there's no run-time
resolution.  All that happens at run-time is instantiating an object
of the closure type and initializing any captured variables (which
means either copying the captured variables or binding references to
them.)


> Can that auto lambda variable be static?

It could be, but if you reference-capture any local variables then
you'll capture the variables from the first execution of the function,
which will be out of scope on the next execution.

> Or possibly, I don't think
> the problem domain is that dynamic that a handful of helper member
> functions wouldn't also do the same job, probably faster too without
> the overhead of declaring the lambda autos.

There should be no overhead.  If you think there is then you'll need
to show some example code demonstrating the problem, because I could
be misunderstanding what you mean.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux