Sign in to follow this  

Assigning lambdas

This topic is 2082 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[quote name='Krohm' timestamp='1336115239' post='4937307']
[quote name='SiCrane' timestamp='1336052848' post='4937096']
The type of a lambda function is a [i]unique anonymous[/i] functor type for every lambda function. Two separate lambdas that have the exact same definition in the exact same scope will have two separate types. As such, trying to get at the exact type of a lambda function is an exercise in futility. Just store the std::function by value.
[/quote]I'm probably going to get bashed - again - for stating my thoughts but... why not to just autobox them to an appropriate std::function at this point?
I mean, really, I feel that a bit rough. It's just me.
[/quote]
In C++, what you don't use, you don't pay for. If you are not using std::function, and since it can't anyways as that's not in the language spec, you don't have to pay for std::function. Furthermore, if it DID do something silly like that (and it is quite silly) it would require an implicit inclusion of the <functional> header.

Share this post


Link to post
Share on other sites
Note that the way std::function is defined more or less requires a heap allocation, so this additional cost would be non-trivial. Besides which, std::function does not have an implicit conversion to a function pointer in case of not capturing variables. That's not something you can add to std::function because it would require the type to have different static behavior based on dynamic information.

Share this post


Link to post
Share on other sites
I'm not completely sold on those... but thank you anyway, I guess I'll just bite the bullet.

Share this post


Link to post
Share on other sites

This topic is 2082 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this