Open gpalmer-latai opened 2 months ago
@gpalmer-latai how big of an issue is this right now? We are currently quite busy with the iceoryx2 C and C++ bindings and I would look into this once we are done with them.
It's not a super huge priority. There are workarounds like using a shared_ptr
or just using std::function
or something instead. These solutions aren't pretty though and we'd still like to use a "fixed size" function wrapper.
I mostly wanted to make sure to document the issue in the off chance someone did have a few free cycles or came across the same issue.
I marked it as good first issue ... let's hope it's not a bottomless pit once someone has a closer look at it
Haha yeah. I mean, on the one hand maybe overloading that function with a signature allowing rvalue references is enough (at least - it appears std::function does this: https://en.cppreference.com/w/cpp/utility/functional/function/function).
On the other hand, I've seen several C++ weekly videos by Jason Turner where he basically explains implementing std::function correctly is notoriously hard and a great exercise to learn about a lot of advanced C++ features.
So a great good first issue :)
Required information
In the docstring for the
iox::function
interface, it is claimed thatHowever in the actual implementation docstring this is contradicted:
And indeed if you attempt to wrap a lambda with a move capture, such as
You'll get a compile error:
Operating system: E.g. Ubuntu 20.04 LTS
Compiler version: E.g. GCC 9.4.0
Eclipse iceoryx version: On an older checkout of main, but should apply to main as well.
Observed result or behaviour:
iox::function
does not support move-only functorsExpected result or behaviour: It should support move-only functors, as documented in the API.
Conditions where it occurred / Performed steps: Try to wrap a lambda with a move-capture.
Additional helpful information