Skip to content

Commit

Permalink
Use boost/bind/bind.hpp to fix warnings on Arch Linux (gazebosim#3156)
Browse files Browse the repository at this point in the history
The boost/bind.hpp file recommends switching to
boost/bind/bind.hpp to avoid legacy syntax for
placeholders.

* Remove unused boost/bind includes
* Add using namespace boost::placeholders if needed
  using narrow scoping when possible, except in
  model_database.cc integration test.
* Use std::bind in gui/building/EditorView.cc
  There was a compilation issue with boost/bind/bind.hpp
  and it was easy to fix it by switching to std::bind with
  std::placeholders::_1.

Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
scpeters authored Jan 12, 2022
1 parent 3806dae commit 897f6cb
Show file tree
Hide file tree
Showing 68 changed files with 97 additions and 73 deletions.
2 changes: 1 addition & 1 deletion deps/opende/src/quickstep_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#ifdef USE_TPROW
// added for threading per constraint rows
#include <boost/thread/recursive_mutex.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include "gazebo/ode/odeinit.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion deps/opende/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "joints/joint.h"
#include "util.h"
#include <boost/thread/recursive_mutex.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <gazebo/ode/timer.h>

#undef REPORT_THREAD_TIMING
Expand Down
2 changes: 1 addition & 1 deletion deps/threadpool/boost/threadpool/detail/pool_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/smart_ptr.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits.hpp>

Expand Down
2 changes: 1 addition & 1 deletion deps/threadpool/boost/threadpool/detail/worker_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <boost/thread.hpp>
#include <boost/thread/exceptions.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>


namespace boost { namespace threadpool { namespace detail
Expand Down
5 changes: 4 additions & 1 deletion gazebo/Master.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <thread>
#include <mutex>

#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/make_shared.hpp>
#include <google/protobuf/descriptor.h>
#include <set>
Expand Down Expand Up @@ -87,6 +87,7 @@ void Master::Init(uint16_t _port)
{
try
{
using namespace boost::placeholders;
this->dataPtr->connection->Listen(_port,
boost::bind(&Master::OnAccept, this, _1));
}
Expand Down Expand Up @@ -136,6 +137,7 @@ void Master::OnAccept(transport::ConnectionPtr _newConnection)
this->dataPtr->connections[index] = _newConnection;

// Start reading from the connection
using namespace boost::placeholders;
_newConnection->AsyncRead(
boost::bind(&Master::OnRead, this, index, _1));
}
Expand All @@ -156,6 +158,7 @@ void Master::OnRead(const unsigned int _connectionIndex,
transport::ConnectionPtr conn = this->dataPtr->connections[_connectionIndex];

// Read the next message
using namespace boost::placeholders;
if (conn && conn->IsOpen())
conn->AsyncRead(boost::bind(&Master::OnRead, this, _connectionIndex, _1));

Expand Down
2 changes: 1 addition & 1 deletion gazebo/common/ModelDatabase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <iostream>

#include <boost/algorithm/string/replace.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/function.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
Expand Down
2 changes: 1 addition & 1 deletion gazebo/common/MovingWindowFilter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <map>

#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>

Expand Down
2 changes: 1 addition & 1 deletion gazebo/common/WeakBind.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define GAZEBO_COMMON_WEAKBIND_HH_

#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

namespace gazebo
{
Expand Down
2 changes: 1 addition & 1 deletion gazebo/common/common_pch.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/assert.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/date_time.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/operations.hpp>
Expand Down
1 change: 0 additions & 1 deletion gazebo/gazebo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*
*/
#include <vector>
#include <boost/bind.hpp>
#include <boost/thread/mutex.hpp>
#include <sdf/sdf.hh>

Expand Down
1 change: 1 addition & 0 deletions gazebo/gazebo_shared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ bool gazebo_shared::setup(const std::string &_prefix, int _argc, char **_argv,
gazebo::common::load();

// The SDF find file callback.
using namespace boost::placeholders;
sdf::setFindCallback(boost::bind(&gazebo::common::find_file, _1));

// Initialize the informational logger. This will log warnings, and
Expand Down
3 changes: 2 additions & 1 deletion gazebo/gui/InsertModelWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <fstream>
#include <cstdlib>

#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <sdf/sdf.hh>
Expand Down Expand Up @@ -128,6 +128,7 @@ InsertModelWidget::InsertModelWidget(QWidget *_parent)
this, SLOT(OnDirectoryChanged(const QString &)));

// Connect a callback to trigger when the model paths are updated.
using namespace boost::placeholders;
this->connections.push_back(
common::SystemPaths::Instance()->updateModelRequest.Connect(
boost::bind(&InsertModelWidget::OnModelUpdateRequest, this, _1)));
Expand Down
3 changes: 2 additions & 1 deletion gazebo/gui/ModelRightMenu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*
*/
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include "gazebo/transport/transport.hh"
#include "gazebo/rendering/UserCamera.hh"
Expand All @@ -34,6 +34,7 @@ using namespace gui;
/////////////////////////////////////////////////
ModelRightMenu::ModelRightMenu()
{
using namespace boost::placeholders;
KeyEventHandler::Instance()->AddReleaseFilter("ModelRightMenu",
boost::bind(&ModelRightMenu::OnKeyRelease, this, _1));

Expand Down
2 changes: 1 addition & 1 deletion gazebo/gui/QTestFixture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# include <mach/mach.h>
#endif // __MACH__

#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <unistd.h>

#include "gazebo/common/Console.hh"
Expand Down
3 changes: 2 additions & 1 deletion gazebo/gui/RenderWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*
*/
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <iomanip>

#include "gazebo/common/CommonIface.hh"
Expand Down Expand Up @@ -97,6 +97,7 @@ RenderWidget::RenderWidget(QWidget *_parent)
this->setLayout(mainLayout);
this->layout()->setContentsMargins(0, 0, 0, 0);

using namespace boost::placeholders;
this->connections.push_back(
gui::Events::ConnectFollow(
boost::bind(&RenderWidget::OnFollow, this, _1)));
Expand Down
2 changes: 1 addition & 1 deletion gazebo/gui/SpaceNav.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*
*/
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <gazebo/gazebo_config.h>
#ifdef HAVE_SPNAV
#include <spnav.h>
Expand Down
3 changes: 2 additions & 1 deletion gazebo/gui/ToolsWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*
*/
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include "gazebo/common/Events.hh"
#include "gazebo/gui/JointControlWidget.hh"
Expand Down Expand Up @@ -60,6 +60,7 @@ ToolsWidget::ToolsWidget(QWidget *_parent)
this->setLayout(mainLayout);

// Listen to entity selection events
using namespace boost::placeholders;
this->connections.push_back(
event::Events::ConnectSetSelectedEntity(
boost::bind(&ToolsWidget::OnSetSelectedEntity, this, _1, _2)));
Expand Down
2 changes: 1 addition & 1 deletion gazebo/gui/building/BuildingEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*
*/
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include "gazebo/gui/qt.h"
#include "gazebo/gui/Actions.hh"
Expand Down
3 changes: 2 additions & 1 deletion gazebo/gui/building/BuildingEditorPalette.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* thenounproject.com
* Stairs designed by Brian Oppenlander from the thenounproject.com
*/
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include "gazebo/gui/building/BuildingEditorPalettePrivate.hh"
#include "gazebo/gui/building/BuildingEditorPalette.hh"
Expand Down Expand Up @@ -261,6 +261,7 @@ BuildingEditorPalette::BuildingEditorPalette(QWidget *_parent)
this->setLayout(scrollLayout);

// Connections
using namespace boost::placeholders;
this->dataPtr->connections.push_back(
gui::editor::Events::ConnectSaveBuildingModel(
boost::bind(&BuildingEditorPalette::OnSaveModel, this, _1)));
Expand Down
20 changes: 10 additions & 10 deletions gazebo/gui/building/EditorView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*
*/

#include <functional>
#include <sstream>
#include <boost/bind.hpp>

#include <ignition/math/Vector2.hh>

Expand Down Expand Up @@ -54,39 +54,39 @@ EditorView::EditorView(QWidget *_parent)

this->connections.push_back(
gui::editor::Events::ConnectCreateBuildingEditorItem(
boost::bind(&EditorView::OnCreateEditorItem, this, _1)));
std::bind(&EditorView::OnCreateEditorItem, this, std::placeholders::_1)));

this->connections.push_back(
gui::editor::Events::ConnectColorSelected(
boost::bind(&EditorView::OnColorSelected, this, _1)));
std::bind(&EditorView::OnColorSelected, this, std::placeholders::_1)));

this->connections.push_back(
gui::editor::Events::ConnectTextureSelected(
boost::bind(&EditorView::OnTextureSelected, this, _1)));
std::bind(&EditorView::OnTextureSelected, this, std::placeholders::_1)));

this->connections.push_back(
gui::editor::Events::ConnectNewBuildingModel(
boost::bind(&EditorView::OnDiscardModel, this)));
std::bind(&EditorView::OnDiscardModel, this)));

this->connections.push_back(
gui::editor::Events::ConnectAddBuildingLevel(
boost::bind(&EditorView::OnAddLevel, this)));
std::bind(&EditorView::OnAddLevel, this)));

this->connections.push_back(
gui::editor::Events::ConnectDeleteBuildingLevel(
boost::bind(&EditorView::OnDeleteLevel, this)));
std::bind(&EditorView::OnDeleteLevel, this)));

this->connections.push_back(
gui::editor::Events::ConnectChangeBuildingLevel(
boost::bind(&EditorView::OnChangeLevel, this, _1)));
std::bind(&EditorView::OnChangeLevel, this, std::placeholders::_1)));

this->connections.push_back(
gui::editor::Events::ConnectShowFloorplan(
boost::bind(&EditorView::OnShowFloorplan, this)));
std::bind(&EditorView::OnShowFloorplan, this)));

this->connections.push_back(
gui::editor::Events::ConnectShowElements(
boost::bind(&EditorView::OnShowElements, this)));
std::bind(&EditorView::OnShowElements, this)));

this->mousePressRotation = 0;

Expand Down
2 changes: 1 addition & 1 deletion gazebo/gui/gui_pch.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* grep --include="*.hh" --include="*.cc" --no-filename -r "#include <" | sort -u
*/
#include <boost/algorithm/string.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/filesystem.hpp>
#include <boost/function.hpp>
#include <boost/lexical_cast.hpp>
Expand Down
3 changes: 2 additions & 1 deletion gazebo/gui/model/ModelEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <string>

#include "gazebo/gazebo_config.h"
Expand Down Expand Up @@ -272,6 +272,7 @@ ModelEditor::ModelEditor(MainWindow *_mainWindow)
connect(this->dataPtr->modelPalette->ModelCreator()->JointMaker(),
SIGNAL(JointAdded()), this, SLOT(OnJointAdded()));

using namespace boost::placeholders;
this->dataPtr->connections.push_back(
gui::Events::ConnectCreateEntity(
boost::bind(&ModelEditor::OnCreateEntity, this, _1, _2)));
Expand Down
2 changes: 1 addition & 1 deletion gazebo/gui/model/ModelTreeWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*
*/
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include <boost/version.hpp>

Expand Down
3 changes: 2 additions & 1 deletion gazebo/gui/terrain/TerrainEditorPalette.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*
*/
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>

#include "gazebo/rendering/Heightmap.hh"
#include "gazebo/rendering/Scene.hh"
Expand Down Expand Up @@ -240,6 +240,7 @@ void TerrainEditorPalette::SetState(const std::string &_state)

// Add an event filter, which allows the TerrainEditor to capture
// mouse events.
using namespace boost::placeholders;
MouseEventHandler::Instance()->AddPressFilter("terrain",
boost::bind(&TerrainEditorPalette::OnMousePress, this, _1));

Expand Down
4 changes: 3 additions & 1 deletion gazebo/physics/Entity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*
*/
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/function.hpp>
#include <boost/thread/recursive_mutex.hpp>

Expand Down Expand Up @@ -199,6 +199,7 @@ void Entity::SetAnimation(common::PoseAnimationPtr _anim)
this->prevAnimationTime = this->world->SimTime();
this->animation = _anim;
this->onAnimationComplete.clear();
using namespace boost::placeholders;
this->animationConnection = event::Events::ConnectWorldUpdateBegin(
boost::bind(&Entity::UpdateAnimation, this, _1));
}
Expand All @@ -212,6 +213,7 @@ void Entity::SetAnimation(const common::PoseAnimationPtr &_anim,
this->prevAnimationTime = this->world->SimTime();
this->animation = _anim;
this->onAnimationComplete = _onComplete;
using namespace boost::placeholders;
this->animationConnection = event::Events::ConnectWorldUpdateBegin(
boost::bind(&Entity::UpdateAnimation, this, _1));
}
Expand Down
2 changes: 1 addition & 1 deletion gazebo/physics/Model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <tbb/blocked_range.h>
#include <float.h>

#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/function.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <ignition/math/Pose3.hh>
Expand Down
2 changes: 1 addition & 1 deletion gazebo/physics/bullet/BulletJoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Date: 15 May 2009
*/

#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <string>

#include "gazebo/common/Assert.hh"
Expand Down
1 change: 0 additions & 1 deletion gazebo/physics/dart/DARTFixedJoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*
*/

#include <boost/bind.hpp>
#include <ignition/math/Helpers.hh>

#include "gazebo/gazebo_config.h"
Expand Down
Loading

0 comments on commit 897f6cb

Please sign in to comment.