-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add non-default constructors to avoid initializing messages with dummy data #749
Comments
@alsora We think that the syntax there isn't supported until C++17 or C++20. Can you check which version supports it? |
Looking at it further, this looks to be a C++20 feature: https://en.cppreference.com/w/cpp/language/aggregate_initialization . Also, it is possible that there don't need to be changes to the core to do this, and it would Just Work(tm) if we upgraded to C++20. |
I think that passing this constant to the constructor and then assign all the fields in the message will serve the same purposes. |
@mauropasse did you test the |
Yes, passing |
It might be nice to have an overload of the LoanedMessage constructor that allows forwarding arguments (i.e. |
This issue has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/rosidl-message-builder-utilize-default-field-values/36745/1 |
Feature request
ROS 2 C++ messages are implemented as data-structures with a default constructor.
Usually the workflow is
This results in first zero-initializing the messages and then populating them again with the true data.
This has a non-negligible overhead in case of messages with large bounded members.
We propose to modify the IDL code to include a constructor that takes argument values, for example in the form of a brace-enclosed list
The text was updated successfully, but these errors were encountered: