You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes fixed_function actually allocates memory and that is quite unexpected and confusing.
The problem is due to alignment: when one of a captured lambda arguments has an alignment, instead of an in-place allocation it can allocate on the heap.
Here's more or less minimal example that I hope demonstrates the problem: https://godbolt.org/z/M6d4GrK3v
Here AlignedVec is aligned by 16 bytes, which makes the lambda capturing it also aligned and this does not pass the is_functor_inplace_allocatable check. And that one leads to a heap allocation.
My C++ template knowledge fails me here. Is there a way I could force fixed_function to use the inplace storage with aligned lambda captures? It would be really cool to make the class just work with any kind of aligned arguments.
The text was updated successfully, but these errors were encountered:
Sometimes
fixed_function
actually allocates memory and that is quite unexpected and confusing.The problem is due to alignment: when one of a captured lambda arguments has an alignment, instead of an in-place allocation it can allocate on the heap.
Here's more or less minimal example that I hope demonstrates the problem: https://godbolt.org/z/M6d4GrK3v
Here
AlignedVec
is aligned by 16 bytes, which makes the lambda capturing it also aligned and this does not pass theis_functor_inplace_allocatable
check. And that one leads to a heap allocation.My C++ template knowledge fails me here. Is there a way I could force
fixed_function
to use the inplace storage with aligned lambda captures? It would be really cool to make the class just work with any kind of aligned arguments.The text was updated successfully, but these errors were encountered: