Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Allow users of function2 to know easily whether their lambdas are stored inplace #36

Open
romange opened this issue Apr 18, 2020 · 4 comments

Comments

@romange
Copy link

romange commented Apr 18, 2020

@Naios Suggestion

For example,

using MyFunction =  fu2::function_base<...>;
auto cb = [foo, bar] {};
static_assert(MyFunction::is_inplace(cb), "Lambda too big!")

This could be useful to maintain code over time and not to break performance-related assumptions..

@Naios
Copy link
Owner

Naios commented Apr 19, 2020

This could be really useful indeed.
Probably it will be implemented in the future.

@Ahajha
Copy link

Ahajha commented Aug 28, 2022

This could also be useful as a configuration option to disallow function objects that are too large for SFO.

using MyFunction =  fu2::function_base<...>;
auto cb1 = [foo, bar] {};
auto cb2 = [foo, bar, baz] {};
MyFunction f1{cb1}; // allowed
//MyFunction f2{cb2}; // too big for SFO, compile error

@Naios
Copy link
Owner

Naios commented Aug 28, 2022

Yes, that's right. Something like fu2::inplace_function (which itself could be a specialization of fu2::function_base) could be quite useful.

@VioletGiraffe
Copy link

VioletGiraffe commented Jan 23, 2023

I came here looking for an in-place move-only function, and I very much vote for both proposals. In some places I want my functions to be in-place only, with a possibility to increase the storage size as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants