diff --git a/docs/coroutine_test_examples.cpp b/docs/coroutine_test_examples.cpp index 78654c9b82..f7d22b05c5 100644 --- a/docs/coroutine_test_examples.cpp +++ b/docs/coroutine_test_examples.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -12,7 +11,7 @@ class FunctionMemberObject explicit FunctionMemberObject(TestFunction func, std::shared_ptr data) : func(func), coroutine_sequence( - boost::bind(&FunctionMemberObject::executeWrapper, this, _1, data)) + std::bind(&FunctionMemberObject::executeWrapper, this, std::placeholders::_1, data)) { } @@ -46,7 +45,7 @@ class DataMemberObject explicit DataMemberObject(TestFunction func, std::shared_ptr data) : data(data), coroutine_sequence( - boost::bind(&DataMemberObject::executeWrapper, this, _1, func)) + std::bind(&DataMemberObject::executeWrapper, this, std::placeholders::_1, func)) { } @@ -78,7 +77,7 @@ class NoMemberObject { public: explicit NoMemberObject(TestFunction validation_function, std::shared_ptr data) - : coroutine_sequence(boost::bind(&NoMemberObject::executeWrapper, this, _1, data, + : coroutine_sequence(std::bind(&NoMemberObject::executeWrapper, this, std::placeholders::_1, data, validation_function)) { } diff --git a/src/software/ai/BUILD b/src/software/ai/BUILD index 974729bc66..e4af6d647a 100644 --- a/src/software/ai/BUILD +++ b/src/software/ai/BUILD @@ -38,7 +38,6 @@ cc_library( "//software/multithreading:subject", "//software/multithreading:threaded_observer", "//software/world", - "@boost//:bind", ], ) diff --git a/src/software/ai/hl/stp/play/play.cpp b/src/software/ai/hl/stp/play/play.cpp index d8931cb61b..33b5f7539c 100644 --- a/src/software/ai/hl/stp/play/play.cpp +++ b/src/software/ai/hl/stp/play/play.cpp @@ -15,7 +15,8 @@ Play::Play(TbotsProto::AiConfig ai_config, bool requires_goalie) goalie_tactic(std::make_shared(ai_config)), halt_tactics(), requires_goalie(requires_goalie), - tactic_sequence(boost::bind(&Play::getNextTacticsWrapper, this, _1)), + tactic_sequence( + std::bind(&Play::getNextTacticsWrapper, this, std::placeholders::_1)), world_ptr_(std::nullopt), obstacle_factory(ai_config.robot_navigation_obstacle_config()) { @@ -42,7 +43,7 @@ PriorityTacticVector Play::getTactics(const WorldPtr &world_ptr) { // Make a new tactic_sequence tactic_sequence = TacticCoroutine::pull_type( - boost::bind(&Play::getNextTacticsWrapper, this, _1)); + std::bind(&Play::getNextTacticsWrapper, this, std::placeholders::_1)); // Run the coroutine. This will call the bound getNextTactics function tactic_sequence(); } @@ -61,7 +62,7 @@ PriorityTacticVector Play::getTactics(const WorldPtr &world_ptr) { // Make a new tactic_sequence tactic_sequence = TacticCoroutine::pull_type( - boost::bind(&Play::getNextTacticsWrapper, this, _1)); + std::bind(&Play::getNextTacticsWrapper, this, std::placeholders::_1)); // Run the coroutine. This will call the bound getNextTactics function tactic_sequence(); if (tactic_sequence) diff --git a/src/software/ai/hl/stp/play/play.h b/src/software/ai/hl/stp/play/play.h index cad46f0206..5eee4f25ba 100644 --- a/src/software/ai/hl/stp/play/play.h +++ b/src/software/ai/hl/stp/play/play.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include diff --git a/src/software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h b/src/software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h index 7afb334997..38283aa7d5 100644 --- a/src/software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h +++ b/src/software/ai/hl/stp/tactic/keep_away/keep_away_fsm.h @@ -11,7 +11,7 @@ struct KeepAwayFSM * * @param ai_config The config to fetch parameters from */ - explicit KeepAwayFSM(const TbotsProto::AiConfig& ai_config) : ai_config(ai_config){}; + explicit KeepAwayFSM(const TbotsProto::AiConfig& ai_config) : ai_config(ai_config) {}; struct ControlParams { diff --git a/src/software/ai/threaded_ai.cpp b/src/software/ai/threaded_ai.cpp index 2a844ab960..985850c8a8 100644 --- a/src/software/ai/threaded_ai.cpp +++ b/src/software/ai/threaded_ai.cpp @@ -1,7 +1,5 @@ #include "software/ai/threaded_ai.h" -#include - #include "proto/message_translation/tbots_protobuf.h" #include "proto/parameters.pb.h" #include "software/ai/hl/stp/play/assigned_tactics_play.h" diff --git a/src/software/embedded/services/network/network.cpp b/src/software/embedded/services/network/network.cpp index 5a7f6d0ff7..1a26d0bcac 100644 --- a/src/software/embedded/services/network/network.cpp +++ b/src/software/embedded/services/network/network.cpp @@ -30,8 +30,8 @@ NetworkService::NetworkService(const RobotId& robot_id, const std::string& ip_ad udp_listener_primitive = std::make_unique>( - primitive_listener_port, std::bind(&NetworkService::primitiveCallback, - this, std::placeholders::_1)); + primitive_listener_port, + [&](TbotsProto::Primitive primitive) { primitiveCallback(primitive); }); } catch (const TbotsNetworkException& e) { @@ -51,7 +51,7 @@ NetworkService::NetworkService(const RobotId& robot_id, const std::string& ip_ad radio_listener_primitive_set = std::make_unique>( - std::bind(&NetworkService::primitiveCallback, this, std::placeholders::_1)); + [&](TbotsProto::Primitive primitive) { primitiveCallback(primitive); }); } void NetworkService::onFullSystemIpNotification( diff --git a/src/software/embedded/services/power.cpp b/src/software/embedded/services/power.cpp index 5699bd8b9f..817c1fb7cc 100644 --- a/src/software/embedded/services/power.cpp +++ b/src/software/embedded/services/power.cpp @@ -1,6 +1,5 @@ #include "software/embedded/services/power.h" -#include #include #include @@ -15,7 +14,7 @@ PowerService::PowerService() throw std::runtime_error("USB not plugged into the Jetson Nano"); } this->uart = std::make_unique(BAUD_RATE, DEVICE_SERIAL_PORT); - this->read_thread = std::thread(boost::bind(&PowerService::continuousRead, this)); + this->read_thread = std::thread(std::bind(&PowerService::continuousRead, this)); } PowerService::~PowerService() diff --git a/src/software/estop/threaded_estop_reader.cpp b/src/software/estop/threaded_estop_reader.cpp index 5b9f1d84ac..7966daf54d 100644 --- a/src/software/estop/threaded_estop_reader.cpp +++ b/src/software/estop/threaded_estop_reader.cpp @@ -1,7 +1,5 @@ - #include "threaded_estop_reader.h" -#include #include #include @@ -12,13 +10,13 @@ ThreadedEstopReader::ThreadedEstopReader(std::unique_ptr uart timer(io_service, boost::posix_time::milliseconds(INTERVAL_BETWEEN_READS_MS)), uart_reader(std::move(uart_reader)) { - estop_thread = std::thread(boost::bind(&ThreadedEstopReader::continousRead, this)); + estop_thread = std::thread(std::bind(&ThreadedEstopReader::continousRead, this)); } void ThreadedEstopReader::continousRead() { timer.async_wait( - boost::bind(&ThreadedEstopReader::tick, this, boost::asio::placeholders::error)); + std::bind(&ThreadedEstopReader::tick, this, boost::asio::placeholders::error)); io_service.run(); } @@ -87,8 +85,8 @@ void ThreadedEstopReader::tick(const boost::system::error_code& error) // Reschedule the timer for interval seconds in the future: timer.expires_from_now(next_interval); // Posts the timer event - timer.async_wait(boost::bind(&ThreadedEstopReader::tick, this, - boost::asio::placeholders::error)); + timer.async_wait(std::bind(&ThreadedEstopReader::tick, this, + boost::asio::placeholders::error)); } } diff --git a/src/software/multithreading/BUILD b/src/software/multithreading/BUILD index c051206e6c..8310a2adff 100644 --- a/src/software/multithreading/BUILD +++ b/src/software/multithreading/BUILD @@ -54,7 +54,6 @@ cc_library( ":observer", ":thread_safe_buffer", "//software/time:duration", - "@boost//:bind", ], ) diff --git a/src/software/multithreading/threaded_observer.hpp b/src/software/multithreading/threaded_observer.hpp index 48b7610bdf..b64ff487be 100644 --- a/src/software/multithreading/threaded_observer.hpp +++ b/src/software/multithreading/threaded_observer.hpp @@ -1,6 +1,5 @@ #pragma once -#include #include #include "software/multithreading/observer.hpp" @@ -88,8 +87,8 @@ ThreadedObserver::ThreadedObserver(size_t buffer_size, bool log_buffer_full) in_destructor(false), IN_DESTRUCTOR_CHECK_PERIOD(Duration::fromSeconds(0.1)) { - pull_from_buffer_thread = std::thread( - boost::bind(&ThreadedObserver::continuouslyPullValuesFromBuffer, this)); + pull_from_buffer_thread = + std::thread(std::bind(&ThreadedObserver::continuouslyPullValuesFromBuffer, this)); } template diff --git a/src/software/networking/udp/proto_udp_listener.hpp b/src/software/networking/udp/proto_udp_listener.hpp index 2c6107dd1f..fff0fd47c1 100644 --- a/src/software/networking/udp/proto_udp_listener.hpp +++ b/src/software/networking/udp/proto_udp_listener.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include #include diff --git a/src/software/networking/udp/threaded_proto_udp_sender.hpp b/src/software/networking/udp/threaded_proto_udp_sender.hpp index a67a6f5a39..92d1fff6ad 100644 --- a/src/software/networking/udp/threaded_proto_udp_sender.hpp +++ b/src/software/networking/udp/threaded_proto_udp_sender.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include diff --git a/src/software/networking/udp/threaded_udp_sender.h b/src/software/networking/udp/threaded_udp_sender.h index ec5e3fc055..a8ab664eee 100644 --- a/src/software/networking/udp/threaded_udp_sender.h +++ b/src/software/networking/udp/threaded_udp_sender.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include "software/networking/udp/udp_sender.h" diff --git a/src/software/networking/udp/udp_listener.cpp b/src/software/networking/udp/udp_listener.cpp index e326040a80..0362514d74 100644 --- a/src/software/networking/udp/udp_listener.cpp +++ b/src/software/networking/udp/udp_listener.cpp @@ -115,9 +115,9 @@ void UdpListener::startListen() // https://stackoverflow.com/questions/34680985/what-is-the-difference-between-asynchronous-programming-and-multithreading socket_.async_receive_from(boost::asio::buffer(raw_received_data_, MAX_BUFFER_LENGTH), sender_endpoint_, - boost::bind(&UdpListener::handleDataReception, this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); + std::bind(&UdpListener::handleDataReception, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); } void UdpListener::handleDataReception(const boost::system::error_code& error, diff --git a/src/software/networking/udp/udp_sender.h b/src/software/networking/udp/udp_sender.h index d935ce4d9d..86a4ac23c8 100644 --- a/src/software/networking/udp/udp_sender.h +++ b/src/software/networking/udp/udp_sender.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include class UdpSender diff --git a/src/software/networking/unix/proto_unix_listener.hpp b/src/software/networking/unix/proto_unix_listener.hpp index 951e498921..6184dfc8e6 100644 --- a/src/software/networking/unix/proto_unix_listener.hpp +++ b/src/software/networking/unix/proto_unix_listener.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include "software/constants.h" @@ -90,9 +89,9 @@ void ProtoUnixListener::startListen() // https://stackoverflow.com/questions/34680985/what-is-the-difference-between-asynchronous-programming-and-multithreading socket_.async_receive_from(boost::asio::buffer(raw_received_data_, UNIX_BUFFER_SIZE), listen_endpoint_, - boost::bind(&ProtoUnixListener::handleDataReception, this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); + std::bind(&ProtoUnixListener::handleDataReception, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); } template diff --git a/src/software/networking/unix/threaded_proto_unix_sender.hpp b/src/software/networking/unix/threaded_proto_unix_sender.hpp index 1700e033aa..029a625cdb 100644 --- a/src/software/networking/unix/threaded_proto_unix_sender.hpp +++ b/src/software/networking/unix/threaded_proto_unix_sender.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include "software/networking/unix/threaded_unix_sender.h" diff --git a/src/software/networking/unix/threaded_unix_sender.cpp b/src/software/networking/unix/threaded_unix_sender.cpp index d1d602ecf2..8451bdf388 100644 --- a/src/software/networking/unix/threaded_unix_sender.cpp +++ b/src/software/networking/unix/threaded_unix_sender.cpp @@ -1,7 +1,6 @@ #include "software/networking/unix/threaded_unix_sender.h" #include -#include #include ThreadedUnixSender::ThreadedUnixSender(const std::string& unix_socket_path) diff --git a/src/software/networking/unix/threaded_unix_sender.h b/src/software/networking/unix/threaded_unix_sender.h index b5a069a542..a67d8109d3 100644 --- a/src/software/networking/unix/threaded_unix_sender.h +++ b/src/software/networking/unix/threaded_unix_sender.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include "software/networking/unix/unix_sender.h" diff --git a/src/software/networking/unix/unix_sender.h b/src/software/networking/unix/unix_sender.h index 6ace95f630..dee2d89f86 100644 --- a/src/software/networking/unix/unix_sender.h +++ b/src/software/networking/unix/unix_sender.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include diff --git a/src/software/simulated_tests/validation/non_terminating_function_validator.cpp b/src/software/simulated_tests/validation/non_terminating_function_validator.cpp index 079ed7fe7c..006b814cbb 100644 --- a/src/software/simulated_tests/validation/non_terminating_function_validator.cpp +++ b/src/software/simulated_tests/validation/non_terminating_function_validator.cpp @@ -2,8 +2,6 @@ #include -#include - NonTerminatingFunctionValidator::NonTerminatingFunctionValidator( ValidationFunction validation_function, std::shared_ptr world) : // We need to provide the world and validation_function in the coroutine function @@ -11,8 +9,8 @@ NonTerminatingFunctionValidator::NonTerminatingFunctionValidator( // otherwise the World inside the coroutine will not update properly when the // pointer is updated, and the wrong validation_function may be run. validation_sequence( - boost::bind(&NonTerminatingFunctionValidator::executeAndCheckForFailuresWrapper, - this, _1, world, validation_function)), + std::bind(&NonTerminatingFunctionValidator::executeAndCheckForFailuresWrapper, + this, std::placeholders::_1, world, validation_function)), world_(world), validation_function_(validation_function) { @@ -24,9 +22,9 @@ std::optional NonTerminatingFunctionValidator::executeAndCheckForFa if (!validation_sequence) { // Re-start the coroutine by re-creating it - validation_sequence = ValidationCoroutine::pull_type(boost::bind( - &NonTerminatingFunctionValidator::executeAndCheckForFailuresWrapper, this, _1, - world_, validation_function_)); + validation_sequence = ValidationCoroutine::pull_type( + std::bind(&NonTerminatingFunctionValidator::executeAndCheckForFailuresWrapper, + this, std::placeholders::_1, world_, validation_function_)); } // Run the coroutine. This will call the bound executeAndCheckForFailuresWrapper diff --git a/src/software/simulated_tests/validation/terminating_function_validator.cpp b/src/software/simulated_tests/validation/terminating_function_validator.cpp index ca8ca098c4..9e0f636739 100644 --- a/src/software/simulated_tests/validation/terminating_function_validator.cpp +++ b/src/software/simulated_tests/validation/terminating_function_validator.cpp @@ -1,7 +1,5 @@ #include "software/simulated_tests/validation/terminating_function_validator.h" -#include - TerminatingFunctionValidator::TerminatingFunctionValidator( ValidationFunction validation_function, std::shared_ptr world) @@ -10,8 +8,8 @@ TerminatingFunctionValidator::TerminatingFunctionValidator( // otherwise the World inside the coroutine will not update properly when the // pointer is updated, and the wrong validation_function may be run. validation_sequence( - boost::bind(&TerminatingFunctionValidator::executeAndCheckForSuccessWrapper, - this, _1, world, validation_function)), + std::bind(&TerminatingFunctionValidator::executeAndCheckForSuccessWrapper, this, + std::placeholders::_1, world, validation_function)), current_error_message("") { }