Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

rosbag_storage: make Bag constructor explicit#835

Merged
dirk-thomas merged 1 commit intoros:kinetic-develfrom
xqms:rosbag-explicit-constructor
Aug 8, 2016
Merged

rosbag_storage: make Bag constructor explicit#835
dirk-thomas merged 1 commit intoros:kinetic-develfrom
xqms:rosbag-explicit-constructor

Conversation

@xqms
Copy link
Copy Markdown
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 <max.schwarz@uni-bonn.de>
@dirk-thomas
Copy link
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants