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

rosbag_storage: make Bag constructor explicit #835

Merged
merged 1 commit into from
Aug 8, 2016

Conversation

xqms
Copy link
Contributor

@xqms xqms commented Jul 14, 2016

This is a very small improvement to the rosbag API (adds "explicit" to the bag constructor)

Previously, it was possible to do something like this:

std::string bagFile = "...";
rosbag::Bag bag(bagFile);

rosbag::View view;
view.addQuery(bagFile, ...);

Note that bagFile is passed to View::addQuery, which does not cause a compiler error, since implicit conversion is allowed by the constructor. Using the view will cause a segfault, since the temporary bag will no longer be around.

I think that there are no good use cases for implicit std::string -> rosbag::Bag conversions, so we should disallow them.

This catches common mistakes such as view.addQuery(bagFileName, ...)

Signed-off-by: Max Schwarz <[email protected]>
@dirk-thomas
Copy link
Member

Thank you for the patch.

@dirk-thomas dirk-thomas merged commit 9ff6955 into ros:kinetic-devel Aug 8, 2016
rsinnet pushed a commit to MisoRobotics/ros_comm that referenced this pull request Jun 19, 2017
rosbag_storage: make Bag constructor explicit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants