Skip to content

Commit 3eef72e

Browse files
wmostrenkopre-commit-ci-lite[bot]williamckha
authored
Replaced instances of boost::bind with std::bind or lambda functions. (UBC-Thunderbots#3410)
* all replacement except for network.cpp * all replacement except for network.cpp * [pre-commit.ci lite] apply automatic fixes * Update coroutine_test_examples.cpp Replaced instances of boost::bind with std::bind * Removed instances of #include <boost/bind> and @boostbind annotations in BUILD files --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: williamckha <williamha@outlook.com>
1 parent d8ef3c6 commit 3eef72e

23 files changed

Lines changed: 31 additions & 53 deletions

docs/coroutine_test_examples.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <boost/bind.hpp>
21
#include <boost/coroutine2/all.hpp>
32
#include <functional>
43
#include <iostream>
@@ -12,7 +11,7 @@ class FunctionMemberObject
1211
explicit FunctionMemberObject(TestFunction func, std::shared_ptr<int> data)
1312
: func(func),
1413
coroutine_sequence(
15-
boost::bind(&FunctionMemberObject::executeWrapper, this, _1, data))
14+
std::bind(&FunctionMemberObject::executeWrapper, this, std::placeholders::_1, data))
1615
{
1716
}
1817

@@ -46,7 +45,7 @@ class DataMemberObject
4645
explicit DataMemberObject(TestFunction func, std::shared_ptr<int> data)
4746
: data(data),
4847
coroutine_sequence(
49-
boost::bind(&DataMemberObject::executeWrapper, this, _1, func))
48+
std::bind(&DataMemberObject::executeWrapper, this, std::placeholders::_1, func))
5049
{
5150
}
5251

@@ -78,7 +77,7 @@ class NoMemberObject
7877
{
7978
public:
8079
explicit NoMemberObject(TestFunction validation_function, std::shared_ptr<int> data)
81-
: coroutine_sequence(boost::bind(&NoMemberObject::executeWrapper, this, _1, data,
80+
: coroutine_sequence(std::bind(&NoMemberObject::executeWrapper, this, std::placeholders::_1, data,
8281
validation_function))
8382
{
8483
}

src/software/ai/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ cc_library(
3838
"//software/multithreading:subject",
3939
"//software/multithreading:threaded_observer",
4040
"//software/world",
41-
"@boost//:bind",
4241
],
4342
)
4443

src/software/ai/hl/stp/play/play.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Play::Play(TbotsProto::AiConfig ai_config, bool requires_goalie)
1515
goalie_tactic(std::make_shared<GoalieTactic>(ai_config)),
1616
halt_tactics(),
1717
requires_goalie(requires_goalie),
18-
tactic_sequence(boost::bind(&Play::getNextTacticsWrapper, this, _1)),
18+
tactic_sequence(
19+
std::bind(&Play::getNextTacticsWrapper, this, std::placeholders::_1)),
1920
world_ptr_(std::nullopt),
2021
obstacle_factory(ai_config.robot_navigation_obstacle_config())
2122
{
@@ -42,7 +43,7 @@ PriorityTacticVector Play::getTactics(const WorldPtr &world_ptr)
4243
{
4344
// Make a new tactic_sequence
4445
tactic_sequence = TacticCoroutine::pull_type(
45-
boost::bind(&Play::getNextTacticsWrapper, this, _1));
46+
std::bind(&Play::getNextTacticsWrapper, this, std::placeholders::_1));
4647
// Run the coroutine. This will call the bound getNextTactics function
4748
tactic_sequence();
4849
}
@@ -61,7 +62,7 @@ PriorityTacticVector Play::getTactics(const WorldPtr &world_ptr)
6162
{
6263
// Make a new tactic_sequence
6364
tactic_sequence = TacticCoroutine::pull_type(
64-
boost::bind(&Play::getNextTacticsWrapper, this, _1));
65+
std::bind(&Play::getNextTacticsWrapper, this, std::placeholders::_1));
6566
// Run the coroutine. This will call the bound getNextTactics function
6667
tactic_sequence();
6768
if (tactic_sequence)

src/software/ai/hl/stp/play/play.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
22

3-
#include <boost/bind.hpp>
43
#include <boost/coroutine2/all.hpp>
54
#include <vector>
65

src/software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct KeepAwayFSM
1111
*
1212
* @param ai_config The config to fetch parameters from
1313
*/
14-
explicit KeepAwayFSM(const TbotsProto::AiConfig& ai_config) : ai_config(ai_config){};
14+
explicit KeepAwayFSM(const TbotsProto::AiConfig& ai_config) : ai_config(ai_config) {};
1515

1616
struct ControlParams
1717
{

src/software/ai/threaded_ai.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include "software/ai/threaded_ai.h"
22

3-
#include <boost/bind.hpp>
4-
53
#include "proto/message_translation/tbots_protobuf.h"
64
#include "proto/parameters.pb.h"
75
#include "software/ai/hl/stp/play/assigned_tactics_play.h"

src/software/embedded/services/network/network.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ NetworkService::NetworkService(const RobotId& robot_id, const std::string& ip_ad
3030

3131
udp_listener_primitive =
3232
std::make_unique<ThreadedProtoUdpListener<TbotsProto::Primitive>>(
33-
primitive_listener_port, std::bind(&NetworkService::primitiveCallback,
34-
this, std::placeholders::_1));
33+
primitive_listener_port,
34+
[&](TbotsProto::Primitive primitive) { primitiveCallback(primitive); });
3535
}
3636
catch (const TbotsNetworkException& e)
3737
{
@@ -51,7 +51,7 @@ NetworkService::NetworkService(const RobotId& robot_id, const std::string& ip_ad
5151

5252
radio_listener_primitive_set =
5353
std::make_unique<ThreadedProtoRadioListener<TbotsProto::Primitive>>(
54-
std::bind(&NetworkService::primitiveCallback, this, std::placeholders::_1));
54+
[&](TbotsProto::Primitive primitive) { primitiveCallback(primitive); });
5555
}
5656

5757
void NetworkService::onFullSystemIpNotification(

src/software/embedded/services/power.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "software/embedded/services/power.h"
22

3-
#include <boost/bind/bind.hpp>
43
#include <boost/filesystem.hpp>
54
#include <cstdint>
65

@@ -15,7 +14,7 @@ PowerService::PowerService()
1514
throw std::runtime_error("USB not plugged into the Jetson Nano");
1615
}
1716
this->uart = std::make_unique<BoostUartCommunication>(BAUD_RATE, DEVICE_SERIAL_PORT);
18-
this->read_thread = std::thread(boost::bind(&PowerService::continuousRead, this));
17+
this->read_thread = std::thread(std::bind(&PowerService::continuousRead, this));
1918
}
2019

2120
PowerService::~PowerService()

src/software/estop/threaded_estop_reader.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
21
#include "threaded_estop_reader.h"
32

4-
#include <boost/bind/bind.hpp>
53
#include <thread>
64
#include <utility>
75

@@ -12,13 +10,13 @@ ThreadedEstopReader::ThreadedEstopReader(std::unique_ptr<UartCommunication> uart
1210
timer(io_service, boost::posix_time::milliseconds(INTERVAL_BETWEEN_READS_MS)),
1311
uart_reader(std::move(uart_reader))
1412
{
15-
estop_thread = std::thread(boost::bind(&ThreadedEstopReader::continousRead, this));
13+
estop_thread = std::thread(std::bind(&ThreadedEstopReader::continousRead, this));
1614
}
1715

1816
void ThreadedEstopReader::continousRead()
1917
{
2018
timer.async_wait(
21-
boost::bind(&ThreadedEstopReader::tick, this, boost::asio::placeholders::error));
19+
std::bind(&ThreadedEstopReader::tick, this, boost::asio::placeholders::error));
2220
io_service.run();
2321
}
2422

@@ -87,8 +85,8 @@ void ThreadedEstopReader::tick(const boost::system::error_code& error)
8785
// Reschedule the timer for interval seconds in the future:
8886
timer.expires_from_now(next_interval);
8987
// Posts the timer event
90-
timer.async_wait(boost::bind(&ThreadedEstopReader::tick, this,
91-
boost::asio::placeholders::error));
88+
timer.async_wait(std::bind(&ThreadedEstopReader::tick, this,
89+
boost::asio::placeholders::error));
9290
}
9391
}
9492

src/software/multithreading/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ cc_library(
5454
":observer",
5555
":thread_safe_buffer",
5656
"//software/time:duration",
57-
"@boost//:bind",
5857
],
5958
)
6059

0 commit comments

Comments
 (0)