From: Francis Dupont Date: Thu, 30 Jul 2020 22:04:26 +0000 (+0200) Subject: [#1308] Got rid of boost function/bind X-Git-Tag: Kea-1.8.0~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2035f64c1c0d0908c71b47a0c321ed66784e391c;p=thirdparty%2Fkea.git [#1308] Got rid of boost function/bind --- diff --git a/src/bin/agent/ca_controller.cc b/src/bin/agent/ca_controller.cc index 134bde5659..092d102b76 100644 --- a/src/bin/agent/ca_controller.cc +++ b/src/bin/agent/ca_controller.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,9 +10,10 @@ #include #include #include -#include +#include using namespace isc::process; +using namespace std::placeholders; namespace isc { namespace agent { @@ -52,31 +53,31 @@ CtrlAgentController::parseFile(const std::string& name) { void CtrlAgentController::registerCommands() { CtrlAgentCommandMgr::instance().registerCommand(BUILD_REPORT_COMMAND, - boost::bind(&DControllerBase::buildReportHandler, this, _1, _2)); + std::bind(&DControllerBase::buildReportHandler, this, _1, _2)); CtrlAgentCommandMgr::instance().registerCommand(CONFIG_GET_COMMAND, - boost::bind(&DControllerBase::configGetHandler, this, _1, _2)); + std::bind(&DControllerBase::configGetHandler, this, _1, _2)); CtrlAgentCommandMgr::instance().registerCommand(CONFIG_RELOAD_COMMAND, - boost::bind(&DControllerBase::configReloadHandler, this, _1, _2)); + std::bind(&DControllerBase::configReloadHandler, this, _1, _2)); CtrlAgentCommandMgr::instance().registerCommand(CONFIG_SET_COMMAND, - boost::bind(&DControllerBase::configSetHandler, this, _1, _2)); + std::bind(&DControllerBase::configSetHandler, this, _1, _2)); CtrlAgentCommandMgr::instance().registerCommand(CONFIG_TEST_COMMAND, - boost::bind(&DControllerBase::configTestHandler, this, _1, _2)); + std::bind(&DControllerBase::configTestHandler, this, _1, _2)); CtrlAgentCommandMgr::instance().registerCommand(CONFIG_WRITE_COMMAND, - boost::bind(&DControllerBase::configWriteHandler, this, _1, _2)); + std::bind(&DControllerBase::configWriteHandler, this, _1, _2)); CtrlAgentCommandMgr::instance().registerCommand(SHUT_DOWN_COMMAND, - boost::bind(&DControllerBase::shutdownHandler, this, _1, _2)); + std::bind(&DControllerBase::shutdownHandler, this, _1, _2)); CtrlAgentCommandMgr::instance().registerCommand(STATUS_GET_COMMAND, - boost::bind(&DControllerBase::statusGetHandler, this, _1, _2)); + std::bind(&DControllerBase::statusGetHandler, this, _1, _2)); CtrlAgentCommandMgr::instance().registerCommand(VERSION_GET_COMMAND, - boost::bind(&DControllerBase::versionGetHandler, this, _1, _2)); + std::bind(&DControllerBase::versionGetHandler, this, _1, _2)); } void diff --git a/src/bin/agent/tests/ca_command_mgr_unittests.cc b/src/bin/agent/tests/ca_command_mgr_unittests.cc index d81ba078ef..842e1f0462 100644 --- a/src/bin/agent/tests/ca_command_mgr_unittests.cc +++ b/src/bin/agent/tests/ca_command_mgr_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -16,11 +16,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include @@ -228,7 +228,7 @@ public: // to this we need to run the server side socket at the same time as the // client. Running IO service in a thread guarantees that the server //responds as soon as it receives the control command. - std::thread th(boost::bind(&IOService::run, getIOService().get())); + std::thread th(std::bind(&IOService::run, getIOService().get())); // Wait for the IO service in thread to actually run. @@ -384,7 +384,7 @@ TEST_F(CtrlAgentCommandMgrTest, forwardListCommands) { // to this we need to run the server side socket at the same time. // Running IO service in a thread guarantees that the server responds // as soon as it receives the control command. - std::thread th(boost::bind(&IOService::run, getIOService().get())); + std::thread th(std::bind(&IOService::run, getIOService().get())); // Wait for the IO service in thread to actually run. server_socket_->waitForRunning(); diff --git a/src/bin/agent/tests/ca_process_unittests.cc b/src/bin/agent/tests/ca_process_unittests.cc index c1ebaf65c7..37e06f66ed 100644 --- a/src/bin/agent/tests/ca_process_unittests.cc +++ b/src/bin/agent/tests/ca_process_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,9 +10,9 @@ #include #include #include -#include #include #include +#include using namespace boost::posix_time; using namespace isc; @@ -68,7 +68,7 @@ TEST_F(CtrlAgentProcessTest, shutdown) { // Use an asiolink IntervalTimer and callback to generate the // shutdown invocation. (Note IntervalTimer setup is in milliseconds). IntervalTimer timer(*getIoService()); - timer.setup(boost::bind(&CtrlAgentProcessTest::genShutdownCallback, this), + timer.setup(std::bind(&CtrlAgentProcessTest::genShutdownCallback, this), 200); // Record start time, and invoke run(). diff --git a/src/bin/agent/tests/ca_response_creator_unittests.cc b/src/bin/agent/tests/ca_response_creator_unittests.cc index 7013d8b022..73a6769751 100644 --- a/src/bin/agent/tests/ca_response_creator_unittests.cc +++ b/src/bin/agent/tests/ca_response_creator_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,13 +12,14 @@ #include #include #include -#include #include +#include using namespace isc::agent; using namespace isc::config; using namespace isc::data; using namespace isc::http; +using namespace std::placeholders; namespace { @@ -37,9 +38,9 @@ public: // Deregisters commands. CtrlAgentCommandMgr::instance().deregisterAll(); CtrlAgentCommandMgr::instance(). - registerCommand("foo", boost::bind(&CtrlAgentResponseCreatorTest:: - fooCommandHandler, - this, _1, _2)); + registerCommand("foo", std::bind(&CtrlAgentResponseCreatorTest:: + fooCommandHandler, + this, _1, _2)); // Make sure that the request has been initialized properly. if (!request_) { diff --git a/src/bin/d2/d2_controller.cc b/src/bin/d2/d2_controller.cc index 30bfbf39b2..c77fe0fa96 100644 --- a/src/bin/d2/d2_controller.cc +++ b/src/bin/d2/d2_controller.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,6 +15,7 @@ using namespace isc::config; using namespace isc::process; +using namespace std::placeholders; namespace isc { namespace d2 { @@ -53,31 +54,31 @@ D2Controller::registerCommands() { // These are the commands always supported by the D2 server. // Please keep the list in alphabetic order. CommandMgr::instance().registerCommand(BUILD_REPORT_COMMAND, - boost::bind(&D2Controller::buildReportHandler, this, _1, _2)); + std::bind(&D2Controller::buildReportHandler, this, _1, _2)); CommandMgr::instance().registerCommand(CONFIG_GET_COMMAND, - boost::bind(&D2Controller::configGetHandler, this, _1, _2)); + std::bind(&D2Controller::configGetHandler, this, _1, _2)); CommandMgr::instance().registerCommand(CONFIG_RELOAD_COMMAND, - boost::bind(&D2Controller::configReloadHandler, this, _1, _2)); + std::bind(&D2Controller::configReloadHandler, this, _1, _2)); CommandMgr::instance().registerCommand(CONFIG_SET_COMMAND, - boost::bind(&D2Controller::configSetHandler, this, _1, _2)); + std::bind(&D2Controller::configSetHandler, this, _1, _2)); CommandMgr::instance().registerCommand(CONFIG_TEST_COMMAND, - boost::bind(&D2Controller::configTestHandler, this, _1, _2)); + std::bind(&D2Controller::configTestHandler, this, _1, _2)); CommandMgr::instance().registerCommand(CONFIG_WRITE_COMMAND, - boost::bind(&D2Controller::configWriteHandler, this, _1, _2)); + std::bind(&D2Controller::configWriteHandler, this, _1, _2)); CommandMgr::instance().registerCommand(SHUT_DOWN_COMMAND, - boost::bind(&D2Controller::shutdownHandler, this, _1, _2)); + std::bind(&D2Controller::shutdownHandler, this, _1, _2)); CommandMgr::instance().registerCommand(STATUS_GET_COMMAND, - boost::bind(&DControllerBase::statusGetHandler, this, _1, _2)); + std::bind(&DControllerBase::statusGetHandler, this, _1, _2)); CommandMgr::instance().registerCommand(VERSION_GET_COMMAND, - boost::bind(&D2Controller::versionGetHandler, this, _1, _2)); + std::bind(&D2Controller::versionGetHandler, this, _1, _2)); } void diff --git a/src/bin/d2/d2_process.cc b/src/bin/d2/d2_process.cc index bee7c7f0f4..19846ba14f 100644 --- a/src/bin/d2/d2_process.cc +++ b/src/bin/d2/d2_process.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -212,7 +212,7 @@ D2Process::configure(isc::data::ConstElementPtr config_set, bool check_only) { isc::data::ConstElementPtr answer; answer = getCfgMgr()->simpleParseConfig(config_set, check_only, - boost::bind(&D2Process::reconfigureCommandChannel, this)); + std::bind(&D2Process::reconfigureCommandChannel, this)); if (check_only) { return (answer); } diff --git a/src/bin/d2/nc_add.cc b/src/bin/d2/nc_add.cc index 8d08392150..b4692a8614 100644 --- a/src/bin/d2/nc_add.cc +++ b/src/bin/d2/nc_add.cc @@ -10,12 +10,11 @@ #include #include -#include -#include - #include #include +#include + namespace isc { namespace d2 { @@ -80,30 +79,30 @@ NameAddTransaction::defineStates() { // Define NameAddTransaction states. defineState(READY_ST, "READY_ST", - boost::bind(&NameAddTransaction::readyHandler, this)); + std::bind(&NameAddTransaction::readyHandler, this)); defineState(SELECTING_FWD_SERVER_ST, "SELECTING_FWD_SERVER_ST", - boost::bind(&NameAddTransaction::selectingFwdServerHandler, this)); + std::bind(&NameAddTransaction::selectingFwdServerHandler, this)); defineState(SELECTING_REV_SERVER_ST, "SELECTING_REV_SERVER_ST", - boost::bind(&NameAddTransaction::selectingRevServerHandler, this)); + std::bind(&NameAddTransaction::selectingRevServerHandler, this)); defineState(ADDING_FWD_ADDRS_ST, "ADDING_FWD_ADDRS_ST", - boost::bind(&NameAddTransaction::addingFwdAddrsHandler, this)); + std::bind(&NameAddTransaction::addingFwdAddrsHandler, this)); defineState(REPLACING_FWD_ADDRS_ST, "REPLACING_FWD_ADDRS_ST", - boost::bind(&NameAddTransaction::replacingFwdAddrsHandler, this)); + std::bind(&NameAddTransaction::replacingFwdAddrsHandler, this)); defineState(REPLACING_REV_PTRS_ST, "REPLACING_REV_PTRS_ST", - boost::bind(&NameAddTransaction::replacingRevPtrsHandler, this)); + std::bind(&NameAddTransaction::replacingRevPtrsHandler, this)); defineState(PROCESS_TRANS_OK_ST, "PROCESS_TRANS_OK_ST", - boost::bind(&NameAddTransaction::processAddOkHandler, this)); + std::bind(&NameAddTransaction::processAddOkHandler, this)); defineState(PROCESS_TRANS_FAILED_ST, "PROCESS_TRANS_FAILED_ST", - boost::bind(&NameAddTransaction::processAddFailedHandler, this)); - + std::bind(&NameAddTransaction::processAddFailedHandler, this)); } + void NameAddTransaction::verifyStates() { // Call superclass implementation first to verify its states. These are diff --git a/src/bin/d2/nc_remove.cc b/src/bin/d2/nc_remove.cc index c3a62d50f3..cd0b14bb59 100644 --- a/src/bin/d2/nc_remove.cc +++ b/src/bin/d2/nc_remove.cc @@ -10,8 +10,7 @@ #include #include -#include -#include +#include namespace isc { namespace d2 { @@ -77,35 +76,35 @@ NameRemoveTransaction::defineStates() { // Define NameRemoveTransaction states. defineState(READY_ST, "READY_ST", - boost::bind(&NameRemoveTransaction::readyHandler, this)); + std::bind(&NameRemoveTransaction::readyHandler, this)); defineState(SELECTING_FWD_SERVER_ST, "SELECTING_FWD_SERVER_ST", - boost::bind(&NameRemoveTransaction::selectingFwdServerHandler, - this)); + std::bind(&NameRemoveTransaction::selectingFwdServerHandler, + this)); defineState(SELECTING_REV_SERVER_ST, "SELECTING_REV_SERVER_ST", - boost::bind(&NameRemoveTransaction::selectingRevServerHandler, - this)); + std::bind(&NameRemoveTransaction::selectingRevServerHandler, + this)); defineState(REMOVING_FWD_ADDRS_ST, "REMOVING_FWD_ADDRS_ST", - boost::bind(&NameRemoveTransaction::removingFwdAddrsHandler, - this)); + std::bind(&NameRemoveTransaction::removingFwdAddrsHandler, + this)); defineState(REMOVING_FWD_RRS_ST, "REMOVING_FWD_RRS_ST", - boost::bind(&NameRemoveTransaction::removingFwdRRsHandler, - this)); + std::bind(&NameRemoveTransaction::removingFwdRRsHandler, + this)); defineState(REMOVING_REV_PTRS_ST, "REMOVING_REV_PTRS_ST", - boost::bind(&NameRemoveTransaction::removingRevPtrsHandler, - this)); + std::bind(&NameRemoveTransaction::removingRevPtrsHandler, + this)); defineState(PROCESS_TRANS_OK_ST, "PROCESS_TRANS_OK_ST", - boost::bind(&NameRemoveTransaction::processRemoveOkHandler, - this)); + std::bind(&NameRemoveTransaction::processRemoveOkHandler, + this)); defineState(PROCESS_TRANS_FAILED_ST, "PROCESS_TRANS_FAILED_ST", - boost::bind(&NameRemoveTransaction::processRemoveFailedHandler, - this)); + std::bind(&NameRemoveTransaction::processRemoveFailedHandler, + this)); } void diff --git a/src/bin/d2/tests/d2_command_unittest.cc b/src/bin/d2/tests/d2_command_unittest.cc index cfa1a81300..497cdfe569 100644 --- a/src/bin/d2/tests/d2_command_unittest.cc +++ b/src/bin/d2/tests/d2_command_unittest.cc @@ -26,6 +26,7 @@ #include using namespace std; +using namespace std::placeholders; using namespace isc; using namespace isc::asiolink; using namespace isc::config; @@ -1159,8 +1160,8 @@ TEST_F(CtrlChannelD2Test, longCommand) { ASSERT_NO_THROW( CommandMgr::instance().registerCommand("foo", - boost::bind(&CtrlChannelD2Test::longCommandHandler, - command.str(), _1, _2)); + std::bind(&CtrlChannelD2Test::longCommandHandler, + command.str(), _1, _2)); ); createUnixChannelServer(); @@ -1218,7 +1219,7 @@ TEST_F(CtrlChannelD2Test, longResponse) { // of a desired size ASSERT_NO_THROW( CommandMgr::instance().registerCommand("foo", - boost::bind(&CtrlChannelD2Test::longResponseHandler, _1, _2)); + std::bind(&CtrlChannelD2Test::longResponseHandler, _1, _2)); ); createUnixChannelServer(); diff --git a/src/bin/d2/tests/d2_process_unittests.cc b/src/bin/d2/tests/d2_process_unittests.cc index 0486212d3f..ff7d067d8b 100644 --- a/src/bin/d2/tests/d2_process_unittests.cc +++ b/src/bin/d2/tests/d2_process_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,10 +13,10 @@ #include #include -#include #include #include +#include #include using namespace std; @@ -549,7 +549,7 @@ TEST_F(D2ProcessTest, normalShutdown) { // Use an asiolink IntervalTimer and callback to generate the // shutdown invocation. (Note IntervalTimer setup is in milliseconds). isc::asiolink::IntervalTimer timer(*getIoService()); - timer.setup(boost::bind(&D2ProcessTest::genShutdownCallback, this), + timer.setup(std::bind(&D2ProcessTest::genShutdownCallback, this), 2 * 1000); // Record start time, and invoke run(). @@ -574,7 +574,7 @@ TEST_F(D2ProcessTest, fatalErrorShutdown) { // Use an asiolink IntervalTimer and callback to generate the // the exception. (Note IntervalTimer setup is in milliseconds). isc::asiolink::IntervalTimer timer(*getIoService()); - timer.setup(boost::bind(&D2ProcessTest::genFatalErrorCallback, this), + timer.setup(std::bind(&D2ProcessTest::genFatalErrorCallback, this), 2 * 1000); // Record start time, and invoke run(). diff --git a/src/bin/d2/tests/d2_queue_mgr_unittests.cc b/src/bin/d2/tests/d2_queue_mgr_unittests.cc index e12a95d0fe..5d1cd4ba0c 100644 --- a/src/bin/d2/tests/d2_queue_mgr_unittests.cc +++ b/src/bin/d2/tests/d2_queue_mgr_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,11 +12,10 @@ #include #include -#include -#include #include #include #include +#include #include using namespace std; @@ -224,8 +223,8 @@ public: FMT_JSON, *this, 100, true)); // Set the test timeout to break any running tasks if they hang. - test_timer_.setup(boost::bind(&QueueMgrUDPTest::testTimeoutHandler, - this), + test_timer_.setup(std::bind(&QueueMgrUDPTest::testTimeoutHandler, + this), TEST_TIMEOUT); } diff --git a/src/bin/d2/tests/dns_client_unittests.cc b/src/bin/d2/tests/dns_client_unittests.cc index 373d472ba9..dc339e0f22 100644 --- a/src/bin/d2/tests/dns_client_unittests.cc +++ b/src/bin/d2/tests/dns_client_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,12 +13,13 @@ #include #include #include -#include #include #include #include +#include using namespace std; +using namespace std::placeholders; using namespace isc; using namespace isc::asiolink; using namespace isc::asiodns; @@ -83,7 +84,7 @@ public: dns_client_.reset(new DNSClient(response_, this)); // Set the test timeout to break any running tasks if they hang. - test_timer_.setup(boost::bind(&DNSClientTest::testTimeoutHandler, this), + test_timer_.setup(std::bind(&DNSClientTest::testTimeoutHandler, this), TEST_TIMEOUT); } @@ -371,9 +372,9 @@ public: udp_socket.async_receive_from(boost::asio::buffer(receive_buffer_, sizeof(receive_buffer_)), remote, - boost::bind(&DNSClientTest::udpReceiveHandler, - this, &udp_socket, &remote, _2, - corrupt_response)); + std::bind(&DNSClientTest::udpReceiveHandler, + this, &udp_socket, &remote, _2, + corrupt_response)); // The socket is now ready to receive the data. Let's post some request // message then. Set timeout to some reasonable value to make sure that @@ -431,10 +432,10 @@ public: udp_socket.async_receive_from(boost::asio::buffer(receive_buffer_, sizeof(receive_buffer_)), remote, - boost::bind(&DNSClientTest:: - TSIGReceiveHandler, this, - &udp_socket, &remote, _2, - client_key, server_key)); + std::bind(&DNSClientTest:: + TSIGReceiveHandler, this, + &udp_socket, &remote, _2, + client_key, server_key)); // The socket is now ready to receive the data. Let's post some request // message then. Set timeout to some reasonable value to make sure that diff --git a/src/bin/d2/tests/nc_test_utils.cc b/src/bin/d2/tests/nc_test_utils.cc index 7b64bca8b1..5e0c92610f 100644 --- a/src/bin/d2/tests/nc_test_utils.cc +++ b/src/bin/d2/tests/nc_test_utils.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -16,6 +16,7 @@ #include using namespace std; +using namespace std::placeholders; using namespace isc; using namespace isc::d2; @@ -96,10 +97,10 @@ FauxServer::receive (const ResponseMode& response_mode, server_socket_->async_receive_from(boost::asio::buffer(receive_buffer_, sizeof(receive_buffer_)), remote_, - boost::bind(&FauxServer::requestHandler, - this, _1, _2, - response_mode, - response_rcode)); + std::bind(&FauxServer::requestHandler, + this, _1, _2, + response_mode, + response_rcode)); } void @@ -226,7 +227,7 @@ TimedIO::runTimedIO(int run_time) { run_time_ = run_time; int cnt = io_service_->get_io_service().poll(); if (cnt == 0) { - timer_.setup(boost::bind(&TimedIO::timesUp, this), run_time_); + timer_.setup(std::bind(&TimedIO::timesUp, this), run_time_); cnt = io_service_->get_io_service().run_one(); timer_.cancel(); } diff --git a/src/bin/d2/tests/nc_trans_unittests.cc b/src/bin/d2/tests/nc_trans_unittests.cc index 9c4382ceba..03a89e7bc3 100644 --- a/src/bin/d2/tests/nc_trans_unittests.cc +++ b/src/bin/d2/tests/nc_trans_unittests.cc @@ -16,10 +16,9 @@ #include #include -#include -#include #include #include +#include using namespace std; using namespace isc; @@ -194,25 +193,25 @@ public: // Define our states. defineState(READY_ST, "READY_ST", - boost::bind(&NameChangeStub::readyHandler, this)); + std::bind(&NameChangeStub::readyHandler, this)); defineState(SELECTING_FWD_SERVER_ST, "SELECTING_FWD_SERVER_ST", - boost::bind(&NameChangeStub::dummyHandler, this)); + std::bind(&NameChangeStub::dummyHandler, this)); defineState(SELECTING_REV_SERVER_ST, "SELECTING_REV_SERVER_ST", - boost::bind(&NameChangeStub::dummyHandler, this)); + std::bind(&NameChangeStub::dummyHandler, this)); defineState(DOING_UPDATE_ST, "DOING_UPDATE_ST", - boost::bind(&NameChangeStub::doingUpdateHandler, - this)); + std::bind(&NameChangeStub::doingUpdateHandler, + this)); defineState(PROCESS_TRANS_OK_ST, "PROCESS_TRANS_OK_ST", - boost::bind(&NameChangeStub:: - processTransDoneHandler, this)); + std::bind(&NameChangeStub:: + processTransDoneHandler, this)); defineState(PROCESS_TRANS_FAILED_ST, "PROCESS_TRANS_FAILED_ST", - boost::bind(&NameChangeStub:: - processTransDoneHandler, this)); + std::bind(&NameChangeStub:: + processTransDoneHandler, this)); } /// @brief Verify the event dictionary. diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index adfb2cef7a..e7bf23fb71 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -37,6 +37,7 @@ using namespace isc::hooks; using namespace isc::stats; using namespace isc::util; using namespace std; +using namespace std::placeholders; namespace { @@ -797,7 +798,7 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) { // Re-open lease and host database with new parameters. try { DatabaseConnection::db_lost_callback = - boost::bind(&ControlledDhcpv4Srv::dbLostCallback, srv, _1); + std::bind(&ControlledDhcpv4Srv::dbLostCallback, srv, _1); CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess(); cfg_db->setAppendedParameters("universe=4"); cfg_db->createManagers(); @@ -884,9 +885,9 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) { boost::shared_ptr failure_count(new unsigned(0)); TimerMgr::instance()-> registerTimer("Dhcp4CBFetchTimer", - boost::bind(&ControlledDhcpv4Srv::cbFetchUpdates, - server_, CfgMgr::instance().getStagingCfg(), - failure_count), + std::bind(&ControlledDhcpv4Srv::cbFetchUpdates, + server_, CfgMgr::instance().getStagingCfg(), + failure_count), fetch_time, asiolink::IntervalTimer::ONE_SHOT); TimerMgr::instance()->setup("Dhcp4CBFetchTimer"); @@ -973,80 +974,80 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t server_port /*= DHCP4_SERVER_P // These are the commands always supported by the DHCPv4 server. // Please keep the list in alphabetic order. CommandMgr::instance().registerCommand("build-report", - boost::bind(&ControlledDhcpv4Srv::commandBuildReportHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandBuildReportHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-backend-pull", - boost::bind(&ControlledDhcpv4Srv::commandConfigBackendPullHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandConfigBackendPullHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-get", - boost::bind(&ControlledDhcpv4Srv::commandConfigGetHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandConfigGetHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-reload", - boost::bind(&ControlledDhcpv4Srv::commandConfigReloadHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandConfigReloadHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-set", - boost::bind(&ControlledDhcpv4Srv::commandConfigSetHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandConfigSetHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-test", - boost::bind(&ControlledDhcpv4Srv::commandConfigTestHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandConfigTestHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-write", - boost::bind(&ControlledDhcpv4Srv::commandConfigWriteHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandConfigWriteHandler, this, _1, _2)); CommandMgr::instance().registerCommand("dhcp-enable", - boost::bind(&ControlledDhcpv4Srv::commandDhcpEnableHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandDhcpEnableHandler, this, _1, _2)); CommandMgr::instance().registerCommand("dhcp-disable", - boost::bind(&ControlledDhcpv4Srv::commandDhcpDisableHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandDhcpDisableHandler, this, _1, _2)); CommandMgr::instance().registerCommand("libreload", - boost::bind(&ControlledDhcpv4Srv::commandLibReloadHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandLibReloadHandler, this, _1, _2)); CommandMgr::instance().registerCommand("leases-reclaim", - boost::bind(&ControlledDhcpv4Srv::commandLeasesReclaimHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandLeasesReclaimHandler, this, _1, _2)); CommandMgr::instance().registerCommand("server-tag-get", - boost::bind(&ControlledDhcpv4Srv::commandServerTagGetHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandServerTagGetHandler, this, _1, _2)); CommandMgr::instance().registerCommand("shutdown", - boost::bind(&ControlledDhcpv4Srv::commandShutdownHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandShutdownHandler, this, _1, _2)); CommandMgr::instance().registerCommand("status-get", - boost::bind(&ControlledDhcpv4Srv::commandStatusGetHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandStatusGetHandler, this, _1, _2)); CommandMgr::instance().registerCommand("version-get", - boost::bind(&ControlledDhcpv4Srv::commandVersionGetHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandVersionGetHandler, this, _1, _2)); // Register statistic related commands CommandMgr::instance().registerCommand("statistic-get", - boost::bind(&StatsMgr::statisticGetHandler, _1, _2)); + std::bind(&StatsMgr::statisticGetHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-reset", - boost::bind(&StatsMgr::statisticResetHandler, _1, _2)); + std::bind(&StatsMgr::statisticResetHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-remove", - boost::bind(&StatsMgr::statisticRemoveHandler, _1, _2)); + std::bind(&StatsMgr::statisticRemoveHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-get-all", - boost::bind(&StatsMgr::statisticGetAllHandler, _1, _2)); + std::bind(&StatsMgr::statisticGetAllHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-reset-all", - boost::bind(&StatsMgr::statisticResetAllHandler, _1, _2)); + std::bind(&StatsMgr::statisticResetAllHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-remove-all", - boost::bind(&StatsMgr::statisticRemoveAllHandler, _1, _2)); + std::bind(&StatsMgr::statisticRemoveAllHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-sample-age-set", - boost::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, _1, _2)); + std::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-sample-age-set-all", - boost::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleAgeAllHandler, this, _1, _2)); CommandMgr::instance().registerCommand("statistic-sample-count-set", - boost::bind(&StatsMgr::statisticSetMaxSampleCountHandler, _1, _2)); + std::bind(&StatsMgr::statisticSetMaxSampleCountHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-sample-count-set-all", - boost::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler, this, _1, _2)); + std::bind(&ControlledDhcpv4Srv::commandStatisticSetMaxSampleCountAllHandler, this, _1, _2)); } void ControlledDhcpv4Srv::shutdownServer(int exit_value) { @@ -1179,8 +1180,8 @@ ControlledDhcpv4Srv::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) { if (!TimerMgr::instance()->isTimerRegistered("Dhcp4DbReconnectTimer")) { TimerMgr::instance()->registerTimer("Dhcp4DbReconnectTimer", - boost::bind(&ControlledDhcpv4Srv::dbReconnect, this, - db_reconnect_ctl), + std::bind(&ControlledDhcpv4Srv::dbReconnect, this, + db_reconnect_ctl), db_reconnect_ctl->retryInterval(), asiolink::IntervalTimer::ONE_SHOT); } diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index d800f21925..983802e726 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -63,11 +63,11 @@ #include #include -#include #include #include #include +#include #include #include #include @@ -82,6 +82,7 @@ using namespace isc::log; using namespace isc::stats; using namespace isc::util; using namespace std; +using namespace std::placeholders; namespace { @@ -3839,8 +3840,8 @@ Dhcpv4Srv::startD2() { // Updates are enabled, so lets start the sender, passing in // our error handler. // This may throw so wherever this is called needs to ready. - d2_mgr.startSender(boost::bind(&Dhcpv4Srv::d2ClientErrorHandler, - this, _1, _2)); + d2_mgr.startSender(std::bind(&Dhcpv4Srv::d2ClientErrorHandler, + this, _1, _2)); } } diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index d339e66a41..dbc432fab3 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -44,6 +44,7 @@ #include using namespace std; +using namespace std::placeholders; using namespace isc; using namespace isc::asiolink; using namespace isc::config; @@ -1528,8 +1529,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, longCommand) { ASSERT_NO_THROW( CommandMgr::instance().registerCommand("foo", - boost::bind(&CtrlChannelDhcpv4SrvTest::longCommandHandler, - command.str(), _1, _2)); + std::bind(&CtrlChannelDhcpv4SrvTest::longCommandHandler, + command.str(), _1, _2)); ); createUnixChannelServer(); @@ -1587,7 +1588,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, longResponse) { // of a desired size. ASSERT_NO_THROW( CommandMgr::instance().registerCommand("foo", - boost::bind(&CtrlChannelDhcpv4SrvTest::longResponseHandler, _1, _2)); + std::bind(&CtrlChannelDhcpv4SrvTest::longResponseHandler, _1, _2)); ); createUnixChannelServer(); diff --git a/src/bin/dhcp4/tests/hooks_unittest.cc b/src/bin/dhcp4/tests/hooks_unittest.cc index 28385223ab..6519d28b77 100644 --- a/src/bin/dhcp4/tests/hooks_unittest.cc +++ b/src/bin/dhcp4/tests/hooks_unittest.cc @@ -701,9 +701,9 @@ public: callout_handle.getArgument("query4", callback_qry_pkt4_); - io_service_->post(boost::bind(&HooksDhcpv4SrvTest::leases4_committed_unpark, - callout_handle.getParkingLotHandlePtr(), - callback_qry_pkt4_)); + io_service_->post(std::bind(&HooksDhcpv4SrvTest::leases4_committed_unpark, + callout_handle.getParkingLotHandlePtr(), + callback_qry_pkt4_)); callout_handle.getParkingLotHandlePtr()->reference(callback_qry_pkt4_); callout_handle.setStatus(CalloutHandle::NEXT_STEP_PARK); diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index faf115a913..4a83f8f742 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -37,6 +37,7 @@ using namespace isc::hooks; using namespace isc::stats; using namespace isc::util; using namespace std; +using namespace std::placeholders; namespace { @@ -800,7 +801,7 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) { // Re-open lease and host database with new parameters. try { DatabaseConnection::db_lost_callback = - boost::bind(&ControlledDhcpv6Srv::dbLostCallback, srv, _1); + std::bind(&ControlledDhcpv6Srv::dbLostCallback, srv, _1); CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess(); cfg_db->setAppendedParameters("universe=6"); cfg_db->createManagers(); @@ -905,9 +906,9 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) { boost::shared_ptr failure_count(new unsigned(0)); TimerMgr::instance()-> registerTimer("Dhcp6CBFetchTimer", - boost::bind(&ControlledDhcpv6Srv::cbFetchUpdates, - server_, CfgMgr::instance().getStagingCfg(), - failure_count), + std::bind(&ControlledDhcpv6Srv::cbFetchUpdates, + server_, CfgMgr::instance().getStagingCfg(), + failure_count), fetch_time, asiolink::IntervalTimer::ONE_SHOT); TimerMgr::instance()->setup("Dhcp6CBFetchTimer"); @@ -992,80 +993,80 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port, // These are the commands always supported by the DHCPv6 server. // Please keep the list in alphabetic order. CommandMgr::instance().registerCommand("build-report", - boost::bind(&ControlledDhcpv6Srv::commandBuildReportHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandBuildReportHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-backend-pull", - boost::bind(&ControlledDhcpv6Srv::commandConfigBackendPullHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandConfigBackendPullHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-get", - boost::bind(&ControlledDhcpv6Srv::commandConfigGetHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandConfigGetHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-reload", - boost::bind(&ControlledDhcpv6Srv::commandConfigReloadHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandConfigReloadHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-test", - boost::bind(&ControlledDhcpv6Srv::commandConfigTestHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandConfigTestHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-write", - boost::bind(&ControlledDhcpv6Srv::commandConfigWriteHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandConfigWriteHandler, this, _1, _2)); CommandMgr::instance().registerCommand("dhcp-disable", - boost::bind(&ControlledDhcpv6Srv::commandDhcpDisableHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandDhcpDisableHandler, this, _1, _2)); CommandMgr::instance().registerCommand("dhcp-enable", - boost::bind(&ControlledDhcpv6Srv::commandDhcpEnableHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandDhcpEnableHandler, this, _1, _2)); CommandMgr::instance().registerCommand("leases-reclaim", - boost::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandLeasesReclaimHandler, this, _1, _2)); CommandMgr::instance().registerCommand("server-tag-get", - boost::bind(&ControlledDhcpv6Srv::commandServerTagGetHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandServerTagGetHandler, this, _1, _2)); CommandMgr::instance().registerCommand("libreload", - boost::bind(&ControlledDhcpv6Srv::commandLibReloadHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandLibReloadHandler, this, _1, _2)); CommandMgr::instance().registerCommand("config-set", - boost::bind(&ControlledDhcpv6Srv::commandConfigSetHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandConfigSetHandler, this, _1, _2)); CommandMgr::instance().registerCommand("shutdown", - boost::bind(&ControlledDhcpv6Srv::commandShutdownHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandShutdownHandler, this, _1, _2)); CommandMgr::instance().registerCommand("status-get", - boost::bind(&ControlledDhcpv6Srv::commandStatusGetHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandStatusGetHandler, this, _1, _2)); CommandMgr::instance().registerCommand("version-get", - boost::bind(&ControlledDhcpv6Srv::commandVersionGetHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandVersionGetHandler, this, _1, _2)); // Register statistic related commands CommandMgr::instance().registerCommand("statistic-get", - boost::bind(&StatsMgr::statisticGetHandler, _1, _2)); + std::bind(&StatsMgr::statisticGetHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-get-all", - boost::bind(&StatsMgr::statisticGetAllHandler, _1, _2)); + std::bind(&StatsMgr::statisticGetAllHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-reset", - boost::bind(&StatsMgr::statisticResetHandler, _1, _2)); + std::bind(&StatsMgr::statisticResetHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-reset-all", - boost::bind(&StatsMgr::statisticResetAllHandler, _1, _2)); + std::bind(&StatsMgr::statisticResetAllHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-remove", - boost::bind(&StatsMgr::statisticRemoveHandler, _1, _2)); + std::bind(&StatsMgr::statisticRemoveHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-remove-all", - boost::bind(&StatsMgr::statisticRemoveAllHandler, _1, _2)); + std::bind(&StatsMgr::statisticRemoveAllHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-sample-age-set", - boost::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, _1, _2)); + std::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-sample-age-set-all", - boost::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleAgeAllHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleAgeAllHandler, this, _1, _2)); CommandMgr::instance().registerCommand("statistic-sample-count-set", - boost::bind(&StatsMgr::statisticSetMaxSampleCountHandler, _1, _2)); + std::bind(&StatsMgr::statisticSetMaxSampleCountHandler, _1, _2)); CommandMgr::instance().registerCommand("statistic-sample-count-set-all", - boost::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleCountAllHandler, this, _1, _2)); + std::bind(&ControlledDhcpv6Srv::commandStatisticSetMaxSampleCountAllHandler, this, _1, _2)); } void ControlledDhcpv6Srv::shutdownServer(int exit_value) { @@ -1198,8 +1199,8 @@ ControlledDhcpv6Srv::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) { if (!TimerMgr::instance()->isTimerRegistered("Dhcp6DbReconnectTimer")) { TimerMgr::instance()->registerTimer("Dhcp6DbReconnectTimer", - boost::bind(&ControlledDhcpv6Srv::dbReconnect, this, - db_reconnect_ctl), + std::bind(&ControlledDhcpv6Srv::dbReconnect, this, + db_reconnect_ctl), db_reconnect_ctl->retryInterval(), asiolink::IntervalTimer::ONE_SHOT); } diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 306ae95e36..9c44466c9c 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -66,7 +66,6 @@ #endif #include -#include #include #include #include @@ -74,6 +73,7 @@ #include #include +#include #include #include #include @@ -91,6 +91,7 @@ using namespace isc::log; using namespace isc::stats; using namespace isc::util; using namespace std; +using namespace std::placeholders; namespace { @@ -3989,8 +3990,8 @@ Dhcpv6Srv::startD2() { // Updates are enabled, so lets start the sender, passing in // our error handler. // This may throw so wherever this is called needs to ready. - d2_mgr.startSender(boost::bind(&Dhcpv6Srv::d2ClientErrorHandler, - this, _1, _2)); + d2_mgr.startSender(std::bind(&Dhcpv6Srv::d2ClientErrorHandler, + this, _1, _2)); } } diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc index 5ae9b04ba2..dd5a5b413a 100644 --- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc @@ -41,6 +41,7 @@ #include using namespace std; +using namespace std::placeholders; using namespace isc; using namespace isc::asiolink; using namespace isc::config; @@ -1556,8 +1557,8 @@ TEST_F(CtrlChannelDhcpv6SrvTest, longCommand) { ASSERT_NO_THROW( CommandMgr::instance().registerCommand("foo", - boost::bind(&CtrlChannelDhcpv6SrvTest::longCommandHandler, - command.str(), _1, _2)); + std::bind(&CtrlChannelDhcpv6SrvTest::longCommandHandler, + command.str(), _1, _2)); ); createUnixChannelServer(); @@ -1615,7 +1616,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, longResponse) { // of a desired size. ASSERT_NO_THROW( CommandMgr::instance().registerCommand("foo", - boost::bind(&CtrlChannelDhcpv6SrvTest::longResponseHandler, _1, _2)); + std::bind(&CtrlChannelDhcpv6SrvTest::longResponseHandler, _1, _2)); ); createUnixChannelServer(); diff --git a/src/bin/dhcp6/tests/hooks_unittest.cc b/src/bin/dhcp6/tests/hooks_unittest.cc index 14730a7b01..50e95fd214 100644 --- a/src/bin/dhcp6/tests/hooks_unittest.cc +++ b/src/bin/dhcp6/tests/hooks_unittest.cc @@ -820,9 +820,9 @@ public: callout_handle.getArgument("query6", callback_qry_pkt6_); - io_service_->post(boost::bind(&HooksDhcpv6SrvTest::leases6_committed_unpark, - callout_handle.getParkingLotHandlePtr(), - callback_qry_pkt6_)); + io_service_->post(std::bind(&HooksDhcpv6SrvTest::leases6_committed_unpark, + callout_handle.getParkingLotHandlePtr(), + callback_qry_pkt6_)); callout_handle.getParkingLotHandlePtr()->reference(callback_qry_pkt6_); callout_handle.setStatus(CalloutHandle::NEXT_STEP_PARK); diff --git a/src/bin/dhcp6/tests/host_unittest.cc b/src/bin/dhcp6/tests/host_unittest.cc index 49b6b2da03..c3ff65a9fc 100644 --- a/src/bin/dhcp6/tests/host_unittest.cc +++ b/src/bin/dhcp6/tests/host_unittest.cc @@ -14,9 +14,8 @@ #include #include #include -#include -#include #include +#include #include #include @@ -724,8 +723,8 @@ public: : Dhcpv6SrvTest(), iface_mgr_test_config_(true), client_(), - do_solicit_(boost::bind(&Dhcp6Client::doSolicit, &client_, true)), - do_solicit_request_(boost::bind(&Dhcp6Client::doSARR, &client_)) { + do_solicit_(std::bind(&Dhcp6Client::doSolicit, &client_, true)), + do_solicit_request_(std::bind(&Dhcp6Client::doSARR, &client_)) { } /// @brief Checks that specified option contains a desired address. @@ -888,7 +887,7 @@ public: /// @param h4 Hint 4. /// @param h5 Hint 5. /// @param h6 Hint 6. - void testMultipleIAs(const boost::function& client_operation, + void testMultipleIAs(const std::function& client_operation, const Reservation& r1 = Reservation::UNSPEC(), const Reservation& r2 = Reservation::UNSPEC(), const Reservation& r3 = Reservation::UNSPEC(), @@ -984,10 +983,10 @@ public: Dhcp6Client client_; /// @brief Pointer to the Dhcp6Client::doSolicit method. - boost::function do_solicit_; + std::function do_solicit_; /// @brief Pointer to the Dhcp6Client::doSARR method. - boost::function do_solicit_request_; + std::function do_solicit_request_; }; void @@ -1096,7 +1095,7 @@ HostTest::testLeaseForIA(const Hint& h) { } void -HostTest::testMultipleIAs(const boost::function& client_operation, +HostTest::testMultipleIAs(const std::function& client_operation, const Reservation& r1, const Reservation& r2, const Reservation& r3, const Reservation& r4, const Reservation& r5, const Reservation& r6, diff --git a/src/bin/netconf/tests/netconf_process_unittests.cc b/src/bin/netconf/tests/netconf_process_unittests.cc index 956f672511..c16b7e7233 100644 --- a/src/bin/netconf/tests/netconf_process_unittests.cc +++ b/src/bin/netconf/tests/netconf_process_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,9 +10,9 @@ #include #include #include -#include #include #include +#include using namespace boost::posix_time; using namespace isc; @@ -66,7 +66,7 @@ TEST_F(NetconfProcessTest, shutdown) { // Use an asiolink IntervalTimer and callback to generate the // shutdown invocation. (Note IntervalTimer setup is in milliseconds). IntervalTimer timer(*getIoService()); - timer.setup(boost::bind(&NetconfProcessTest::genShutdownCallback, this), + timer.setup(std::bind(&NetconfProcessTest::genShutdownCallback, this), 200); // Record start time, and invoke run(). diff --git a/src/bin/perfdhcp/receiver.cc b/src/bin/perfdhcp/receiver.cc index 65a8987f10..61deba5eb1 100644 --- a/src/bin/perfdhcp/receiver.cc +++ b/src/bin/perfdhcp/receiver.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,7 +9,7 @@ #include -#include +#include using namespace std; using namespace isc::dhcp; @@ -27,7 +27,7 @@ Receiver::start() { run_flag_.clear(); isc_throw(isc::Unexpected, "run_flag_ should be false."); } - recv_thread_.reset(new std::thread(boost::bind(&Receiver::run, this))); + recv_thread_.reset(new std::thread(std::bind(&Receiver::run, this))); } void diff --git a/src/hooks/dhcp/high_availability/communication_state.cc b/src/hooks/dhcp/high_availability/communication_state.cc index d495adc983..76eb2a1331 100644 --- a/src/hooks/dhcp/high_availability/communication_state.cc +++ b/src/hooks/dhcp/high_availability/communication_state.cc @@ -21,9 +21,9 @@ #include #include -#include #include +#include #include #include @@ -112,13 +112,13 @@ CommunicationState::setPartnerScopes(ConstElementPtr new_scopes) { void CommunicationState::startHeartbeat(const long interval, - const boost::function& heartbeat_impl) { + const std::function& heartbeat_impl) { startHeartbeatInternal(interval, heartbeat_impl); } void CommunicationState::startHeartbeatInternal(const long interval, - const boost::function& heartbeat_impl) { + const std::function& heartbeat_impl) { bool settings_modified = false; // If we're setting the heartbeat for the first time, it should diff --git a/src/hooks/dhcp/high_availability/communication_state.h b/src/hooks/dhcp/high_availability/communication_state.h index 5549a20c24..b78d192b62 100644 --- a/src/hooks/dhcp/high_availability/communication_state.h +++ b/src/hooks/dhcp/high_availability/communication_state.h @@ -15,7 +15,6 @@ #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include #include +#include #include #include #include @@ -129,7 +129,7 @@ public: /// @param heartbeat_impl pointer to the heartbeat implementation /// function. void startHeartbeat(const long interval, - const boost::function& heartbeat_impl); + const std::function& heartbeat_impl); protected: @@ -139,7 +139,7 @@ protected: /// @param heartbeat_impl pointer to the heartbeat implementation /// function. void startHeartbeatInternal(const long interval = 0, - const boost::function& heartbeat_impl = 0); + const std::function& heartbeat_impl = 0); public: @@ -394,7 +394,7 @@ protected: boost::posix_time::ptime poke_time_; /// @brief Pointer to the function providing heartbeat implementation. - boost::function heartbeat_impl_; + std::function heartbeat_impl_; /// @brief Last known state of the partner server. /// diff --git a/src/hooks/dhcp/high_availability/ha_service.cc b/src/hooks/dhcp/high_availability/ha_service.cc index 63cb3e9c64..4f21e4a864 100644 --- a/src/hooks/dhcp/high_availability/ha_service.cc +++ b/src/hooks/dhcp/high_availability/ha_service.cc @@ -22,9 +22,9 @@ #include #include #include -#include #include #include +#include #include using namespace isc::asiolink; @@ -35,6 +35,7 @@ using namespace isc::hooks; using namespace isc::http; using namespace isc::log; using namespace isc::util; +using namespace std::placeholders; namespace isc { namespace ha { @@ -99,47 +100,47 @@ HAService::defineStates() { StateModel::defineStates(); defineState(HA_BACKUP_ST, stateToString(HA_BACKUP_ST), - boost::bind(&HAService::backupStateHandler, this), + std::bind(&HAService::backupStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_BACKUP_ST)->getPausing()); defineState(HA_HOT_STANDBY_ST, stateToString(HA_HOT_STANDBY_ST), - boost::bind(&HAService::normalStateHandler, this), + std::bind(&HAService::normalStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_HOT_STANDBY_ST)->getPausing()); defineState(HA_LOAD_BALANCING_ST, stateToString(HA_LOAD_BALANCING_ST), - boost::bind(&HAService::normalStateHandler, this), + std::bind(&HAService::normalStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_LOAD_BALANCING_ST)->getPausing()); defineState(HA_IN_MAINTENANCE_ST, stateToString(HA_IN_MAINTENANCE_ST), - boost::bind(&HAService::inMaintenanceStateHandler, this), + std::bind(&HAService::inMaintenanceStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_IN_MAINTENANCE_ST)->getPausing()); defineState(HA_PARTNER_DOWN_ST, stateToString(HA_PARTNER_DOWN_ST), - boost::bind(&HAService::partnerDownStateHandler, this), + std::bind(&HAService::partnerDownStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_PARTNER_DOWN_ST)->getPausing()); defineState(HA_PARTNER_IN_MAINTENANCE_ST, stateToString(HA_PARTNER_IN_MAINTENANCE_ST), - boost::bind(&HAService::partnerInMaintenanceStateHandler, this), + std::bind(&HAService::partnerInMaintenanceStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_PARTNER_IN_MAINTENANCE_ST)->getPausing()); defineState(HA_PASSIVE_BACKUP_ST, stateToString(HA_PASSIVE_BACKUP_ST), - boost::bind(&HAService::passiveBackupStateHandler, this), + std::bind(&HAService::passiveBackupStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_PASSIVE_BACKUP_ST)->getPausing()); defineState(HA_READY_ST, stateToString(HA_READY_ST), - boost::bind(&HAService::readyStateHandler, this), + std::bind(&HAService::readyStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_READY_ST)->getPausing()); defineState(HA_SYNCING_ST, stateToString(HA_SYNCING_ST), - boost::bind(&HAService::syncingStateHandler, this), + std::bind(&HAService::syncingStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_SYNCING_ST)->getPausing()); defineState(HA_TERMINATED_ST, stateToString(HA_TERMINATED_ST), - boost::bind(&HAService::terminatedStateHandler, this), + std::bind(&HAService::terminatedStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_TERMINATED_ST)->getPausing()); defineState(HA_WAITING_ST, stateToString(HA_WAITING_ST), - boost::bind(&HAService::waitingStateHandler, this), + std::bind(&HAService::waitingStateHandler, this), config_->getStateMachineConfig()->getStateConfig(HA_WAITING_ST)->getPausing()); } @@ -1092,8 +1093,8 @@ HAService::asyncSendLeaseUpdate(const QueryPtrType& query, } }, HttpClient::RequestTimeout(TIMEOUT_DEFAULT_HTTP_CLIENT_REQUEST), - boost::bind(&HAService::clientConnectHandler, this, _1, _2), - boost::bind(&HAService::clientCloseHandler, this, _1) + std::bind(&HAService::clientConnectHandler, this, _1, _2), + std::bind(&HAService::clientCloseHandler, this, _1) ); // The number of pending requests is the number of requests for which we @@ -1372,8 +1373,8 @@ HAService::asyncSendHeartbeat() { runModel(HA_HEARTBEAT_COMPLETE_EVT); }, HttpClient::RequestTimeout(TIMEOUT_DEFAULT_HTTP_CLIENT_REQUEST), - boost::bind(&HAService::clientConnectHandler, this, _1, _2), - boost::bind(&HAService::clientCloseHandler, this, _1) + std::bind(&HAService::clientConnectHandler, this, _1, _2), + std::bind(&HAService::clientCloseHandler, this, _1) ); } @@ -1388,8 +1389,8 @@ void HAService::startHeartbeat() { if (config_->getHeartbeatDelay() > 0) { communication_state_->startHeartbeat(config_->getHeartbeatDelay(), - boost::bind(&HAService::asyncSendHeartbeat, - this)); + std::bind(&HAService::asyncSendHeartbeat, + this)); } } @@ -1463,8 +1464,8 @@ HAService::asyncDisableDHCPService(HttpClient& http_client, } }, HttpClient::RequestTimeout(TIMEOUT_DEFAULT_HTTP_CLIENT_REQUEST), - boost::bind(&HAService::clientConnectHandler, this, _1, _2), - boost::bind(&HAService::clientCloseHandler, this, _1) + std::bind(&HAService::clientConnectHandler, this, _1, _2), + std::bind(&HAService::clientCloseHandler, this, _1) ); } @@ -1535,8 +1536,8 @@ HAService::asyncEnableDHCPService(HttpClient& http_client, } }, HttpClient::RequestTimeout(TIMEOUT_DEFAULT_HTTP_CLIENT_REQUEST), - boost::bind(&HAService::clientConnectHandler, this, _1, _2), - boost::bind(&HAService::clientCloseHandler, this, _1) + std::bind(&HAService::clientConnectHandler, this, _1, _2), + std::bind(&HAService::clientCloseHandler, this, _1) ); } @@ -1776,8 +1777,8 @@ HAService::asyncSyncLeasesInternal(http::HttpClient& http_client, } }, HttpClient::RequestTimeout(config_->getSyncTimeout()), - boost::bind(&HAService::clientConnectHandler, this, _1, _2), - boost::bind(&HAService::clientCloseHandler, this, _1) + std::bind(&HAService::clientConnectHandler, this, _1, _2), + std::bind(&HAService::clientCloseHandler, this, _1) ); } @@ -2011,8 +2012,8 @@ HAService::processMaintenanceStart() { captured_error_message = error_message; }, HttpClient::RequestTimeout(TIMEOUT_DEFAULT_HTTP_CLIENT_REQUEST), - boost::bind(&HAService::clientConnectHandler, this, _1, _2), - boost::bind(&HAService::clientCloseHandler, this, _1) + std::bind(&HAService::clientConnectHandler, this, _1, _2), + std::bind(&HAService::clientCloseHandler, this, _1) ); // Run the IO service until it is stopped by any of the callbacks. This @@ -2119,8 +2120,8 @@ HAService::processMaintenanceCancel() { } }, HttpClient::RequestTimeout(TIMEOUT_DEFAULT_HTTP_CLIENT_REQUEST), - boost::bind(&HAService::clientConnectHandler, this, _1, _2), - boost::bind(&HAService::clientCloseHandler, this, _1) + std::bind(&HAService::clientConnectHandler, this, _1, _2), + std::bind(&HAService::clientCloseHandler, this, _1) ); // Run the IO service until it is stopped by any of the callbacks. This @@ -2203,7 +2204,7 @@ HAService::clientConnectHandler(const boost::system::error_code& ec, int tcp_nat // We are registerin the socket only to interrupt main-thread // select(). IfaceMgr::instance().addExternalSocket(tcp_native_fd, - boost::bind(&HAService::socketReadyHandler, this, _1) + std::bind(&HAService::socketReadyHandler, this, _1) ); } diff --git a/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc b/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc index 8fccd838d3..64342f01f3 100644 --- a/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/communication_state_unittest.cc @@ -17,11 +17,9 @@ #include #include - #include -#include -#include #include +#include using namespace isc; using namespace isc::asiolink; @@ -59,8 +57,8 @@ public: /// @brief Returns test heartbeat implementation. /// /// @return Pointer to heartbeat implementation function under test. - boost::function getHeartbeatImpl() { - return (boost::bind(&CommunicationStateTest::heartbeatImpl, this)); + std::function getHeartbeatImpl() { + return (std::bind(&CommunicationStateTest::heartbeatImpl, this)); } /// @brief Test heartbeat implementation. diff --git a/src/hooks/dhcp/high_availability/tests/ha_test.cc b/src/hooks/dhcp/high_availability/tests/ha_test.cc index 78f86011a0..bfe2ab18c0 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_test.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_test.cc @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include @@ -72,7 +72,7 @@ void HATest::runIOService(long ms) { io_service_->get_io_service().reset(); IntervalTimer timer(*io_service_); - timer.setup(boost::bind(&IOService::stop, io_service_), ms, + timer.setup(std::bind(&IOService::stop, io_service_), ms, IntervalTimer::ONE_SHOT); io_service_->run(); timer.cancel(); @@ -83,7 +83,7 @@ HATest::runIOService(long ms, std::function stop_condition) { io_service_->get_io_service().reset(); IntervalTimer timer(*io_service_); bool timeout = false; - timer.setup(boost::bind(&HATest::stopIOServiceHandler, this, boost::ref(timeout)), + timer.setup(std::bind(&HATest::stopIOServiceHandler, this, std::ref(timeout)), ms, IntervalTimer::ONE_SHOT); while (!stop_condition() && !timeout) { @@ -101,10 +101,10 @@ HATest::runIOServiceInThread() { std::mutex mutex; std::condition_variable condvar; - io_service_->post(boost::bind(&HATest::signalServiceRunning, this, boost::ref(running), - boost::ref(mutex), boost::ref(condvar))); + io_service_->post(std::bind(&HATest::signalServiceRunning, this, std::ref(running), + std::ref(mutex), std::ref(condvar))); boost::shared_ptr - th(new std::thread(boost::bind(&IOService::run, io_service_.get()))); + th(new std::thread(std::bind(&IOService::run, io_service_.get()))); std::unique_lock lock(mutex); while (!running) { diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc index 8023921993..c8142083cc 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -24,6 +24,7 @@ #include using namespace std; +using namespace std::placeholders; using namespace isc; using namespace isc::hooks; using namespace isc::config; @@ -657,8 +658,8 @@ public: D2ClientConfigPtr cfg(new D2ClientConfig()); ASSERT_NO_THROW(cfg->enableUpdates(true)); ASSERT_NO_THROW(CfgMgr::instance().setD2ClientConfig(cfg)); - d2_mgr_.startSender(boost::bind(&LeaseCmdsTest::d2ErrorHandler, this, - _1, _2)); + d2_mgr_.startSender(std::bind(&LeaseCmdsTest::d2ErrorHandler, this, + _1, _2)); } /// @brief Disables DHCP-DDNS updates. diff --git a/src/lib/asiodns/io_fetch.cc b/src/lib/asiodns/io_fetch.cc index 4a3b8a3190..d5405c518b 100644 --- a/src/lib/asiodns/io_fetch.cc +++ b/src/lib/asiodns/io_fetch.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -22,10 +22,10 @@ #include #include -#include #include #include +#include #include // for some IPC/network system calls #include #include @@ -252,7 +252,7 @@ IOFetch::operator()(boost::system::error_code ec, size_t length) { // first two bytes of the packet). data_->msgbuf->writeUint16At(data_->qid, 0); - } + } } // If we timeout, we stop, which will can cancel outstanding I/Os and @@ -260,7 +260,7 @@ IOFetch::operator()(boost::system::error_code ec, size_t length) { if (data_->timeout != -1) { data_->timer.expires_from_now(boost::posix_time::milliseconds( data_->timeout)); - data_->timer.async_wait(boost::bind(&IOFetch::stop, *this, + data_->timer.async_wait(std::bind(&IOFetch::stop, *this, TIME_OUT)); } @@ -279,7 +279,7 @@ IOFetch::operator()(boost::system::error_code ec, size_t length) { data_->origin = ASIODNS_SEND_DATA; BOOST_ASIO_CORO_YIELD data_->socket->asyncSend(data_->msgbuf->getData(), data_->msgbuf->getLength(), data_->remote_snd.get(), *this); - + // Now receive the response. Since TCP may not receive the entire // message in one operation, we need to loop until we have received // it. (This can't be done within the asyncReceive() method because @@ -298,7 +298,7 @@ IOFetch::operator()(boost::system::error_code ec, size_t length) { // the expected amount of data. Then we need to loop until we have // received all the data before copying it back to the user's buffer. // And we want to minimize the amount of copying... - + data_->origin = ASIODNS_READ_DATA; data_->cumulative = 0; // No data yet received data_->offset = 0; // First data into start of buffer diff --git a/src/lib/asiodns/tests/io_fetch_unittest.cc b/src/lib/asiodns/tests/io_fetch_unittest.cc index 02db1e4a38..12d139765b 100644 --- a/src/lib/asiodns/tests/io_fetch_unittest.cc +++ b/src/lib/asiodns/tests/io_fetch_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -20,23 +20,24 @@ #include #include -#include #include #include #include +#include #include #include #include #include #include +using namespace boost::asio::ip; using namespace boost::asio; +using namespace isc::asiolink; using namespace isc::dns; using namespace isc::util; -using namespace boost::asio::ip; +using namespace std::placeholders; using namespace std; -using namespace isc::asiolink; namespace isc { namespace asiodns { @@ -241,7 +242,7 @@ public: // Initiate a read on the socket. cumulative_ = 0; socket->async_receive(boost::asio::buffer(receive_buffer_, sizeof(receive_buffer_)), - boost::bind(&IOFetchTest::tcpReceiveHandler, this, socket, _1, _2)); + std::bind(&IOFetchTest::tcpReceiveHandler, this, socket, _1, _2)); } /// \brief Completion handler for receiving TCP data @@ -278,7 +279,7 @@ public: if (!complete) { socket->async_receive(boost::asio::buffer((receive_buffer_ + cumulative_), (sizeof(receive_buffer_) - cumulative_)), - boost::bind(&IOFetchTest::tcpReceiveHandler, this, socket, _1, _2)); + std::bind(&IOFetchTest::tcpReceiveHandler, this, socket, _1, _2)); return; } @@ -336,7 +337,7 @@ public: // Pointer to data to send size_t amount = 16; // Amount of data to send if (send_cumulative_ < (2 * amount)) { - + // First or second time through, send at most 16 bytes amount = min(amount, (send_buffer_.size() - send_cumulative_)); @@ -366,8 +367,8 @@ public: // ... and send it. The amount sent is also passed as the first // argument of the send callback, as a check. socket->async_send(boost::asio::buffer(send_ptr, amount), - boost::bind(&IOFetchTest::tcpSendHandler, this, - amount, socket, _1, _2)); + std::bind(&IOFetchTest::tcpSendHandler, this, + amount, socket, _1, _2)); } /// \brief Completion Handler for Sending TCP data @@ -409,8 +410,8 @@ public: // socket over which data should be sent as an argument to that // function. timer_.expires_from_now(boost::posix_time::milliseconds(SEND_INTERVAL)); - timer_.async_wait(boost::bind(&IOFetchTest::tcpSendData, this, - socket)); + timer_.async_wait(std::bind(&IOFetchTest::tcpSendData, this, + socket)); } } @@ -475,10 +476,10 @@ public: // Post the query service_.get_io_service().post(fetch); - // Post query_.stop() (yes, the boost::bind thing is just + // Post query_.stop() (yes, the std::bind thing is just // query_.stop()). service_.get_io_service().post( - boost::bind(&IOFetch::stop, fetch, IOFetch::STOPPED)); + std::bind(&IOFetch::stop, fetch, IOFetch::STOPPED)); // Run both of them. run() returns when everything in the I/O service // queue has completed. @@ -549,7 +550,7 @@ public: tcp::acceptor acceptor(service_.get_io_service(), tcp::endpoint(tcp::v4(), TEST_PORT)); acceptor.async_accept(socket, - boost::bind(&IOFetchTest::tcpAcceptHandler, this, &socket, _1)); + std::bind(&IOFetchTest::tcpAcceptHandler, this, &socket, _1)); // Post the TCP fetch object to send the query and receive the response. service_.get_io_service().post(tcp_fetch_); @@ -583,9 +584,9 @@ public: socket.async_receive_from(boost::asio::buffer(receive_buffer_, sizeof(receive_buffer_)), remote, - boost::bind(&IOFetchTest::udpReceiveHandler, - this, &remote, &socket, - _1, _2, bad_qid, second_send)); + std::bind(&IOFetchTest::udpReceiveHandler, + this, &remote, &socket, + _1, _2, bad_qid, second_send)); service_.get_io_service().post(udp_fetch_); if (debug_) { cout << "udpSendReceive: async_receive_from posted," diff --git a/src/lib/asiolink/interval_timer.cc b/src/lib/asiolink/interval_timer.cc index 5a3061e688..b74901969e 100644 --- a/src/lib/asiolink/interval_timer.cc +++ b/src/lib/asiolink/interval_timer.cc @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -17,6 +16,7 @@ #include #include +#include #include using namespace std; @@ -118,7 +118,7 @@ IntervalTimerImpl::setup(const IntervalTimer::Callback& cbfunc, "equal to 0"); } // Call back function should not be empty. - if (cbfunc.empty()) { + if (!cbfunc) { isc_throw(isc::InvalidParameter, "Callback function is empty"); } @@ -140,9 +140,9 @@ IntervalTimerImpl::update() { timer_.expires_from_now(boost::posix_time::millisec(long(interval_))); // Reset timer. // Pass a function bound with a shared_ptr to this. - timer_.async_wait(boost::bind(&IntervalTimerImpl::callback, - shared_from_this(), - boost::asio::placeholders::error)); + timer_.async_wait(std::bind(&IntervalTimerImpl::callback, + shared_from_this(), + std::placeholders::_1)); //error } catch (const boost::system::system_error& e) { isc_throw(isc::Unexpected, "Failed to update timer: " << e.what()); } catch (const boost::bad_weak_ptr&) { diff --git a/src/lib/asiolink/interval_timer.h b/src/lib/asiolink/interval_timer.h index a942d8e525..5dc8b71ab3 100644 --- a/src/lib/asiolink/interval_timer.h +++ b/src/lib/asiolink/interval_timer.h @@ -7,8 +7,8 @@ #ifndef ASIOLINK_INTERVAL_TIMER_H #define ASIOLINK_INTERVAL_TIMER_H 1 -#include #include +#include #include @@ -52,7 +52,7 @@ class IntervalTimerImpl; class IntervalTimer { public: /// \name The type of timer callback function - typedef boost::function Callback; + typedef std::function Callback; /// \brief Defines possible timer modes used to setup a timer. /// - REPEATING - Timer will reschedule itself after each expiration diff --git a/src/lib/asiolink/io_service.cc b/src/lib/asiolink/io_service.cc index 4aebddc9b3..cbc3ccca38 100644 --- a/src/lib/asiolink/io_service.cc +++ b/src/lib/asiolink/io_service.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -17,19 +17,19 @@ namespace isc { namespace asiolink { namespace { -// A trivial wrapper for boost::function. SunStudio doesn't seem to be capable -// of handling a boost::function object if directly passed to +// A trivial wrapper for std::function. SunStudio doesn't seem to be capable +// of handling a std::function object if directly passed to // io_service::post(). class CallbackWrapper { public: - CallbackWrapper(const boost::function& callback) : + CallbackWrapper(const std::function& callback) : callback_(callback) {} void operator()() { callback_(); } private: - boost::function callback_; + std::function callback_; }; } @@ -90,7 +90,7 @@ public: /// It will eventually be removed once the wrapper interface is /// generalized. boost::asio::io_service& get_io_service() { return io_service_; }; - void post(const boost::function& callback) { + void post(const std::function& callback) { const CallbackWrapper wrapper(callback); io_service_.post(wrapper); } @@ -138,7 +138,7 @@ IOService::get_io_service() { } void -IOService::post(const boost::function& callback) { +IOService::post(const std::function& callback) { return (io_impl_->post(callback)); } diff --git a/src/lib/asiolink/io_service.h b/src/lib/asiolink/io_service.h index 025c33e727..acfb97361c 100644 --- a/src/lib/asiolink/io_service.h +++ b/src/lib/asiolink/io_service.h @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,7 +7,9 @@ #ifndef ASIOLINK_IO_SERVICE_H #define ASIOLINK_IO_SERVICE_H 1 -#include +#include +#include +#include namespace boost { namespace asio { @@ -90,7 +92,7 @@ public: /// /// It may be used to implement "background" work, for example (doing stuff /// by small bits that are called from time to time). - void post(const boost::function& callback); + void post(const std::function& callback); private: IOServiceImpl* io_impl_; diff --git a/src/lib/asiolink/tests/io_service_unittest.cc b/src/lib/asiolink/tests/io_service_unittest.cc index 882169d4d7..05fc5ac479 100644 --- a/src/lib/asiolink/tests/io_service_unittest.cc +++ b/src/lib/asiolink/tests/io_service_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,7 +9,7 @@ #include #include -#include +#include #include using namespace isc::asiolink; @@ -26,9 +26,9 @@ TEST(IOService, post) { std::vector called; IOService service; // Post two events - service.post(boost::bind(&postedEvent, &called, 1)); - service.post(boost::bind(&postedEvent, &called, 2)); - service.post(boost::bind(&postedEvent, &called, 3)); + service.post(std::bind(&postedEvent, &called, 1)); + service.post(std::bind(&postedEvent, &called, 2)); + service.post(std::bind(&postedEvent, &called, 3)); // They have not yet been called EXPECT_TRUE(called.empty()); // Process two events diff --git a/src/lib/asiolink/tests/tcp_acceptor_unittest.cc b/src/lib/asiolink/tests/tcp_acceptor_unittest.cc index a88a07a971..8229bbcdb7 100644 --- a/src/lib/asiolink/tests/tcp_acceptor_unittest.cc +++ b/src/lib/asiolink/tests/tcp_acceptor_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,11 +11,10 @@ #include #include #include -#include -#include #include #include #include +#include #include #include #include @@ -83,7 +82,8 @@ public: endpoint(boost::asio::ip::address::from_string(SERVER_ADDRESS), SERVER_PORT); socket_.async_connect(endpoint, - boost::bind(&TCPClient::connectHandler, this,_1)); + std::bind(&TCPClient::connectHandler, this, + std::placeholders::_1)); } /// @brief Callback function for connect(). @@ -128,7 +128,7 @@ typedef boost::shared_ptr TCPClientPtr; /// @brief A signature of the function implementing callback for the /// TCPAcceptor. -typedef boost::function TCPAcceptorCallback; +typedef std::function TCPAcceptorCallback; /// @brief TCPAcceptor using TCPAcceptorCallback. typedef TCPAcceptor TestTCPAcceptor; @@ -205,8 +205,8 @@ public: endpoint_(asio_endpoint_), test_timer_(io_service_), connections_(), clients_(), connections_num_(0), aborted_connections_num_(0), max_connections_(1) { - test_timer_.setup(boost::bind(&TCPAcceptorTest::timeoutHandler, this), - TEST_TIMEOUT, IntervalTimer::ONE_SHOT); + test_timer_.setup(std::bind(&TCPAcceptorTest::timeoutHandler, this), + TEST_TIMEOUT, IntervalTimer::ONE_SHOT); } /// @brief Destructor. @@ -250,8 +250,8 @@ public: /// accepting new connections. The instance of the Acceptor object is /// retained in the connections_ list. void accept() { - TCPAcceptorCallback cb = boost::bind(&TCPAcceptorTest::acceptHandler, - this, _1); + TCPAcceptorCallback cb = std::bind(&TCPAcceptorTest::acceptHandler, + this, std::placeholders::_1); AcceptorPtr conn(new Acceptor(io_service_, acceptor_, cb)); connections_.push_back(conn); connections_.back()->accept(); diff --git a/src/lib/asiolink/testutils/test_server_unix_socket.cc b/src/lib/asiolink/testutils/test_server_unix_socket.cc index 11d462246a..d22b9802a1 100644 --- a/src/lib/asiolink/testutils/test_server_unix_socket.cc +++ b/src/lib/asiolink/testutils/test_server_unix_socket.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -55,9 +54,9 @@ public: /// @brief Starts asynchronous read from the socket. void start() { socket_->async_read_some(boost::asio::buffer(&raw_buf_[0], raw_buf_.size()), - boost::bind(&Connection::readHandler, shared_from_this(), - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); + std::bind(&Connection::readHandler, shared_from_this(), + std::placeholders::_1, // error + std::placeholders::_2)); // bytes_transferred } /// @brief Closes the socket. @@ -253,7 +252,7 @@ TestServerUnixSocket::generateCustomResponse(const uint64_t response_size) { void TestServerUnixSocket::startTimer(const long test_timeout) { - test_timer_.setup(boost::bind(&TestServerUnixSocket::timeoutHandler, this), + test_timer_.setup(std::bind(&TestServerUnixSocket::timeoutHandler, this), test_timeout, IntervalTimer::ONE_SHOT); } @@ -275,8 +274,8 @@ TestServerUnixSocket::bindServerSocket(const bool use_thread) { // when the thread has already started and the IO service is running. The // main thread can move forward when it receives this signal from the handler. if (use_thread) { - io_service_.post(boost::bind(&TestServerUnixSocket::signalRunning, - this)); + io_service_.post(std::bind(&TestServerUnixSocket::signalRunning, + this)); } } @@ -293,8 +292,8 @@ TestServerUnixSocket::acceptHandler(const boost::system::error_code& ec) { void TestServerUnixSocket::accept() { server_acceptor_.async_accept(*(connection_pool_->getSocket()), - boost::bind(&TestServerUnixSocket::acceptHandler, this, - boost::asio::placeholders::error)); + std::bind(&TestServerUnixSocket::acceptHandler, this, + std::placeholders::_1)); // error } void diff --git a/src/lib/asiolink/testutils/test_server_unix_socket.h b/src/lib/asiolink/testutils/test_server_unix_socket.h index d5aec7575a..c272ee7ce4 100644 --- a/src/lib/asiolink/testutils/test_server_unix_socket.h +++ b/src/lib/asiolink/testutils/test_server_unix_socket.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -43,7 +43,7 @@ class ConnectionPool; /// using @ref TestServerUnixSocket::getResponseNum. /// /// This class uses @c shared_from_this() to pass its instance to the -/// @c boost::bind function, thus the caller must store shared pointer +/// @c std::bind function, thus the caller must store shared pointer /// to this object. class TestServerUnixSocket { public: diff --git a/src/lib/asiolink/unix_domain_socket.cc b/src/lib/asiolink/unix_domain_socket.cc index d32684f067..f59e68a553 100644 --- a/src/lib/asiolink/unix_domain_socket.cc +++ b/src/lib/asiolink/unix_domain_socket.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,10 +8,11 @@ #include #include -#include #include +#include #include using namespace boost::asio::local; +using namespace std::placeholders; namespace isc { namespace asiolink { @@ -164,8 +165,9 @@ public: void UnixDomainSocketImpl::asyncConnect(const stream_protocol::endpoint& endpoint, const UnixDomainSocket::ConnectHandler& handler) { - auto local_handler = boost::bind(&UnixDomainSocketImpl::connectHandler, shared_from_this(), - handler, _1); + auto local_handler = std::bind(&UnixDomainSocketImpl::connectHandler, + shared_from_this(), + handler, _1); socket_.async_connect(endpoint, local_handler); } @@ -193,8 +195,9 @@ UnixDomainSocketImpl::asyncSend(const void* data, const size_t length, void UnixDomainSocketImpl::doSend(const boost::asio::const_buffers_1& buffer, const UnixDomainSocket::Handler& handler) { - auto local_handler = boost::bind(&UnixDomainSocketImpl::sendHandler, shared_from_this(), - handler, buffer, _1, _2); + auto local_handler = std::bind(&UnixDomainSocketImpl::sendHandler, + shared_from_this(), + handler, buffer, _1, _2); socket_.async_send(buffer, local_handler); } @@ -225,8 +228,9 @@ UnixDomainSocketImpl::asyncReceive(void* data, const size_t length, void UnixDomainSocketImpl::doReceive(const boost::asio::mutable_buffers_1& buffer, const UnixDomainSocket::Handler& handler) { - auto local_handler = boost::bind(&UnixDomainSocketImpl::receiveHandler, shared_from_this(), - handler, buffer, _1, _2); + auto local_handler = std::bind(&UnixDomainSocketImpl::receiveHandler, + shared_from_this(), + handler, buffer, _1, _2); socket_.async_receive(buffer, 0, local_handler); } diff --git a/src/lib/cc/json_feed.cc b/src/lib/cc/json_feed.cc index a092e7b38d..d1f2e8ef1b 100644 --- a/src/lib/cc/json_feed.cc +++ b/src/lib/cc/json_feed.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,7 +8,7 @@ #include #include -#include +#include using namespace isc::data; using namespace isc::util; @@ -135,17 +135,17 @@ JSONFeed::defineStates() { StateModel::defineStates(); defineState(RECEIVE_START_ST, "RECEIVE_START_ST", - boost::bind(&JSONFeed::receiveStartHandler, this)); + std::bind(&JSONFeed::receiveStartHandler, this)); defineState(WHITESPACE_BEFORE_JSON_ST, "WHITESPACE_BEFORE_JSON_ST", - boost::bind(&JSONFeed::whiteSpaceBeforeJSONHandler, this)); + std::bind(&JSONFeed::whiteSpaceBeforeJSONHandler, this)); defineState(INNER_JSON_ST, "INNER_JSON_ST", - boost::bind(&JSONFeed::innerJSONHandler, this)); + std::bind(&JSONFeed::innerJSONHandler, this)); defineState(STRING_JSON_ST, "STRING_JSON_ST", - boost::bind(&JSONFeed::stringJSONHandler, this)); + std::bind(&JSONFeed::stringJSONHandler, this)); defineState(ESCAPE_JSON_ST, "ESCAPE_JSON_ST", - boost::bind(&JSONFeed::escapeJSONHandler, this)); + std::bind(&JSONFeed::escapeJSONHandler, this)); defineState(JSON_END_ST, "JSON_END_ST", - boost::bind(&JSONFeed::endJSONHandler, this)); + std::bind(&JSONFeed::endJSONHandler, this)); } void diff --git a/src/lib/config/base_command_mgr.cc b/src/lib/config/base_command_mgr.cc index 17d058a804..324c239728 100644 --- a/src/lib/config/base_command_mgr.cc +++ b/src/lib/config/base_command_mgr.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,10 +11,11 @@ #include #include #include -#include +#include using namespace isc::data; using namespace isc::hooks; +using namespace std::placeholders; namespace { @@ -40,8 +41,8 @@ namespace isc { namespace config { BaseCommandMgr::BaseCommandMgr() { - registerCommand("list-commands", boost::bind(&BaseCommandMgr::listCommandsHandler, - this, _1, _2)); + registerCommand("list-commands", std::bind(&BaseCommandMgr::listCommandsHandler, + this, _1, _2)); } void @@ -107,7 +108,7 @@ BaseCommandMgr::deregisterAll() { // code, just in tests. handlers_.clear(); registerCommand("list-commands", - boost::bind(&BaseCommandMgr::listCommandsHandler, this, _1, _2)); + std::bind(&BaseCommandMgr::listCommandsHandler, this, _1, _2)); } isc::data::ConstElementPtr diff --git a/src/lib/config/base_command_mgr.h b/src/lib/config/base_command_mgr.h index dd4ee153da..88a3099630 100644 --- a/src/lib/config/base_command_mgr.h +++ b/src/lib/config/base_command_mgr.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -79,7 +79,7 @@ public: /// @param name name of the commands /// @param params parameters specific to the command /// @return response (created with createAnswer()) - typedef boost::function CommandHandler; /// @brief Defines extended command handler type. @@ -92,7 +92,7 @@ public: /// @param params parameters specific to the command /// @param original original control command. /// @return response (created with createAnswer()) - typedef boost::function ExtendedCommandHandler; diff --git a/src/lib/config/client_connection.cc b/src/lib/config/client_connection.cc index a22442295e..6217c1aae1 100644 --- a/src/lib/config/client_connection.cc +++ b/src/lib/config/client_connection.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,9 +11,9 @@ #include #include #include -#include #include #include +#include using namespace isc::asiolink; @@ -123,8 +123,8 @@ ClientConnectionImpl::ClientConnectionImpl(IOService& io_service) void ClientConnectionImpl::scheduleTimer(ClientConnection::Handler handler) { if (timeout_ > 0) { - timer_.setup(boost::bind(&ClientConnectionImpl::timeoutCallback, - this, handler), + timer_.setup(std::bind(&ClientConnectionImpl::timeoutCallback, + this, handler), timeout_, IntervalTimer::ONE_SHOT); } } diff --git a/src/lib/config/command_mgr.cc b/src/lib/config/command_mgr.cc index 945b198c24..34f76103bc 100644 --- a/src/lib/config/command_mgr.cc +++ b/src/lib/config/command_mgr.cc @@ -20,9 +20,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -30,6 +30,7 @@ using namespace isc; using namespace isc::asiolink; using namespace isc::config; using namespace isc::data; +using namespace std::placeholders; namespace { @@ -94,7 +95,7 @@ public: /// @brief This method schedules timer or reschedules existing timer. void scheduleTimer() { - timeout_timer_.setup(boost::bind(&Connection::timeoutHandler, this), + timeout_timer_.setup(std::bind(&Connection::timeoutHandler, this), timeout_, IntervalTimer::ONE_SHOT); } @@ -137,8 +138,8 @@ public: /// process received data. void doReceive() { socket_->asyncReceive(&buf_[0], sizeof(buf_), - boost::bind(&Connection::receiveHandler, - shared_from_this(), _1, _2)); + std::bind(&Connection::receiveHandler, + shared_from_this(), _1, _2)); } /// @brief Starts asynchronous send over the unix domain socket. @@ -151,7 +152,7 @@ public: void doSend() { size_t chunk_size = (response_.size() < BUF_SIZE) ? response_.size() : BUF_SIZE; socket_->asyncSend(&response_[0], chunk_size, - boost::bind(&Connection::sendHandler, shared_from_this(), _1, _2)); + std::bind(&Connection::sendHandler, shared_from_this(), _1, _2)); // Asynchronous send has been scheduled and we need to indicate this // to break the synchronous select(). The handler should clear this diff --git a/src/lib/database/database_connection.h b/src/lib/database/database_connection.h index 4c093532eb..990dc08c6d 100644 --- a/src/lib/database/database_connection.h +++ b/src/lib/database/database_connection.h @@ -9,9 +9,9 @@ #include #include -#include #include #include +#include #include #include @@ -220,7 +220,7 @@ public: bool configuredReadOnly() const; /// @brief Defines a callback prototype for propogating events upward - typedef boost::function DbLostCallback; + typedef std::function DbLostCallback; /// @brief Invokes the connection's lost connectivity callback /// diff --git a/src/lib/database/tests/database_connection_unittest.cc b/src/lib/database/tests/database_connection_unittest.cc index 68bc500998..2d5db619d8 100644 --- a/src/lib/database/tests/database_connection_unittest.cc +++ b/src/lib/database/tests/database_connection_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,7 +12,7 @@ #include #include -#include +#include using namespace isc::data; using namespace isc::db; @@ -84,6 +84,7 @@ TEST_F(DatabaseConnectionCallbackTest, NoDbLostCallback) { TEST_F(DatabaseConnectionCallbackTest, dbLostCallback) { /// Create a Database configuration that includes the reconnect /// control parameters. + using namespace std::placeholders; DatabaseConnection::ParameterMap pmap; pmap[std::string("type")] = std::string("test"); pmap[std::string("max-reconnect-tries")] = std::string("3"); @@ -91,7 +92,7 @@ TEST_F(DatabaseConnectionCallbackTest, dbLostCallback) { /// Install the callback. DatabaseConnection::db_lost_callback = - boost::bind(&DatabaseConnectionCallbackTest::dbLostCallback, this, _1); + std::bind(&DatabaseConnectionCallbackTest::dbLostCallback, this, _1); /// Create the connection.. DatabaseConnection datasrc(pmap); diff --git a/src/lib/dhcp/iface_mgr.cc b/src/lib/dhcp/iface_mgr.cc index d9c6cc7523..99f4370398 100644 --- a/src/lib/dhcp/iface_mgr.cc +++ b/src/lib/dhcp/iface_mgr.cc @@ -19,11 +19,11 @@ #include #include -#include #include #include #include +#include #include #include @@ -749,7 +749,7 @@ IfaceMgr::startDHCPReceiver(const uint16_t family) { } dhcp_receiver_.reset(new WatchedThread()); - dhcp_receiver_->start(boost::bind(&IfaceMgr::receiveDHCP4Packets, this)); + dhcp_receiver_->start(std::bind(&IfaceMgr::receiveDHCP4Packets, this)); break; case AF_INET6: // If the queue doesn't exist, packet queing has been configured @@ -759,7 +759,7 @@ IfaceMgr::startDHCPReceiver(const uint16_t family) { } dhcp_receiver_.reset(new WatchedThread()); - dhcp_receiver_->start(boost::bind(&IfaceMgr::receiveDHCP6Packets, this)); + dhcp_receiver_->start(std::bind(&IfaceMgr::receiveDHCP6Packets, this)); break; default: isc_throw (BadValue, "startDHCPReceiver: invalid family: " << family); diff --git a/src/lib/dhcp/iface_mgr.h b/src/lib/dhcp/iface_mgr.h index 5c6a47df94..4e72f47463 100644 --- a/src/lib/dhcp/iface_mgr.h +++ b/src/lib/dhcp/iface_mgr.h @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -29,6 +28,7 @@ #include #include +#include #include #include #include @@ -621,7 +621,7 @@ typedef boost::shared_ptr IfaceMgrPtr; /// /// @param errmsg An error message. typedef -boost::function IfaceMgrErrorMsgCallback; +std::function IfaceMgrErrorMsgCallback; /// @brief Handles network interfaces, transmission and reception. /// @@ -633,7 +633,7 @@ class IfaceMgr : public boost::noncopyable { public: /// Defines callback used when data is received over external sockets. /// @param fd socket descriptor of the ready socket - typedef boost::function SocketCallback; + typedef std::function SocketCallback; /// Keeps callback information for external sockets. struct SocketCallbackInfo { diff --git a/src/lib/dhcp/tests/iface_mgr_unittest.cc b/src/lib/dhcp/tests/iface_mgr_unittest.cc index 22fa697e1c..dcd6bcbae2 100644 --- a/src/lib/dhcp/tests/iface_mgr_unittest.cc +++ b/src/lib/dhcp/tests/iface_mgr_unittest.cc @@ -17,13 +17,13 @@ #include #include -#include #include #include #include #include #include +#include #include #include @@ -31,6 +31,7 @@ #include using namespace std; +using namespace std::placeholders; using namespace isc; using namespace isc::asiolink; using namespace isc::dhcp; @@ -1853,7 +1854,7 @@ TEST_F(IfaceMgrTest, openSockets4IfaceDown) { // should be called when the IfaceMgr fails to open socket on an interface // on which the server is configured to listen. isc::dhcp::IfaceMgrErrorMsgCallback error_handler = - boost::bind(&IfaceMgrTest::ifaceMgrErrorHandler, this, _1); + std::bind(&IfaceMgrTest::ifaceMgrErrorHandler, this, _1); ASSERT_NO_THROW(IfaceMgr::instance().openSockets4(DHCP4_SERVER_PORT, true, error_handler)); @@ -1956,7 +1957,7 @@ TEST_F(IfaceMgrTest, openSocket4ErrorHandler) { // Install an error handler before trying to open sockets. This handler // should be called when the IfaceMgr fails to open socket on eth0. isc::dhcp::IfaceMgrErrorMsgCallback error_handler = - boost::bind(&IfaceMgrTest::ifaceMgrErrorHandler, this, _1); + std::bind(&IfaceMgrTest::ifaceMgrErrorHandler, this, _1); // The openSockets4 should detect that there is another socket already // open and bound to the same address and port. An attempt to open // another socket and bind to this address and port should fail. @@ -2296,7 +2297,7 @@ TEST_F(IfaceMgrTest, openSockets6IfaceDown) { // Install an error handler before trying to open sockets. This handler // should be called when the IfaceMgr fails to open socket on eth0. isc::dhcp::IfaceMgrErrorMsgCallback error_handler = - boost::bind(&IfaceMgrTest::ifaceMgrErrorHandler, this, _1); + std::bind(&IfaceMgrTest::ifaceMgrErrorHandler, this, _1); // Simulate opening sockets using the dummy packet filter. bool success = false; @@ -2423,7 +2424,7 @@ TEST_F(IfaceMgrTest, openSocket6ErrorHandler) { // Install an error handler before trying to open sockets. This handler // should be called when the IfaceMgr fails to open socket on eth0. isc::dhcp::IfaceMgrErrorMsgCallback error_handler = - boost::bind(&IfaceMgrTest::ifaceMgrErrorHandler, this, _1); + std::bind(&IfaceMgrTest::ifaceMgrErrorHandler, this, _1); // The openSockets6 should detect that a socket has been already // opened on eth0 and an attempt to open another socket and bind to // the same address and port should fail. diff --git a/src/lib/dhcp_ddns/ncr_udp.cc b/src/lib/dhcp_ddns/ncr_udp.cc index b47ca1c2af..b0ee2ac5e8 100644 --- a/src/lib/dhcp_ddns/ncr_udp.cc +++ b/src/lib/dhcp_ddns/ncr_udp.cc @@ -9,7 +9,7 @@ #include #include -#include +#include namespace isc { namespace dhcp_ddns { @@ -19,7 +19,7 @@ UDPCallback::UDPCallback (RawBufferPtr& buffer, const size_t buf_size, UDPEndpointPtr& data_source, const UDPCompletionHandler& handler) : handler_(handler), data_(new Data(buffer, buf_size, data_source)) { - if (handler.empty()) { + if (!handler) { isc_throw(NcrUDPError, "UDPCallback - handler can't be null"); } @@ -70,11 +70,12 @@ NameChangeUDPListener(const isc::asiolink::IOAddress& ip_address, // Instantiate the receive callback. This gets passed into each receive. // Note that the callback constructor is passed an instance method // pointer to our completion handler method, receiveCompletionHandler. + using namespace std::placeholders; RawBufferPtr buffer(new uint8_t[RECV_BUF_MAX]); UDPEndpointPtr data_source(new asiolink::UDPEndpoint()); recv_callback_.reset(new UDPCallback(buffer, RECV_BUF_MAX, data_source, - boost::bind(&NameChangeUDPListener:: + std::bind(&NameChangeUDPListener:: receiveCompletionHandler, this, _1, _2))); } @@ -205,10 +206,11 @@ NameChangeUDPSender(const isc::asiolink::IOAddress& ip_address, // Instantiate the send callback. This gets passed into each send. // Note that the callback constructor is passed the an instance method // pointer to our completion handler, sendCompletionHandler. + using namespace std::placeholders; RawBufferPtr buffer(new uint8_t[SEND_BUF_MAX]); UDPEndpointPtr data_source(new asiolink::UDPEndpoint()); send_callback_.reset(new UDPCallback(buffer, SEND_BUF_MAX, data_source, - boost::bind(&NameChangeUDPSender:: + std::bind(&NameChangeUDPSender:: sendCompletionHandler, this, _1, _2))); } diff --git a/src/lib/dhcp_ddns/ncr_udp.h b/src/lib/dhcp_ddns/ncr_udp.h index 155b0480ec..01284aff7e 100644 --- a/src/lib/dhcp_ddns/ncr_udp.h +++ b/src/lib/dhcp_ddns/ncr_udp.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -127,7 +127,7 @@ public: class UDPCallback; /// @brief Defines a function pointer for NameChangeRequest completion handlers. -typedef boost::function +typedef std::function UDPCompletionHandler; /// @brief Defines a dynamically allocated shared array. diff --git a/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc index 29b207bc68..f910d5eada 100644 --- a/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc +++ b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc @@ -16,9 +16,8 @@ #include #include -#include -#include +#include #include #include @@ -173,8 +172,8 @@ public: FMT_JSON, *this, true)); // Set the test timeout to break any running tasks if they hang. - test_timer_.setup(boost::bind(&NameChangeUDPListenerTest:: - testTimeoutHandler, this), + test_timer_.setup(std::bind(&NameChangeUDPListenerTest:: + testTimeoutHandler, this), TEST_TIMEOUT); } @@ -978,8 +977,8 @@ public: FMT_JSON, *this, 100, true)); // Set the test timeout to break any running tasks if they hang. - test_timer_.setup(boost::bind(&NameChangeUDPTest::testTimeoutHandler, - this), + test_timer_.setup(std::bind(&NameChangeUDPTest::testTimeoutHandler, + this), TEST_TIMEOUT); // Disble multi-threading MultiThreadingMgr::instance().setMode(false); diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 9962d10125..e1c3e69aea 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -43,7 +43,6 @@ #include #include - using namespace isc::asiolink; using namespace isc::dhcp; using namespace isc::dhcp_ddns; @@ -51,6 +50,7 @@ using namespace isc::hooks; using namespace isc::stats; using namespace isc::util; using namespace isc::data; +using namespace std::placeholders; namespace { @@ -2596,8 +2596,8 @@ AllocEngine::reclaimExpiredLease(const Lease6Ptr& lease, // expired-reclaimed state or simply remove it. LeaseMgr& lease_mgr = LeaseMgrFactory::instance(); reclaimLeaseInDatabase(lease, remove_lease, - boost::bind(&LeaseMgr::updateLease6, - &lease_mgr, _1)); + std::bind(&LeaseMgr::updateLease6, + &lease_mgr, _1)); } } @@ -2692,8 +2692,8 @@ AllocEngine::reclaimExpiredLease(const Lease4Ptr& lease, // expired-reclaimed state or simply remove it. LeaseMgr& lease_mgr = LeaseMgrFactory::instance(); reclaimLeaseInDatabase(lease, remove_lease, - boost::bind(&LeaseMgr::updateLease4, - &lease_mgr, _1)); + std::bind(&LeaseMgr::updateLease4, + &lease_mgr, _1)); } } @@ -2849,7 +2849,7 @@ AllocEngine::reclaimDeclined(const Lease6Ptr& lease) { template void AllocEngine::reclaimLeaseInDatabase(const LeasePtrType& lease, const bool remove_lease, - const boost::function& + const std::function& lease_update_fun) const { LeaseMgr& lease_mgr = LeaseMgrFactory::instance(); @@ -2858,7 +2858,7 @@ void AllocEngine::reclaimLeaseInDatabase(const LeasePtrType& lease, // expired-reclaimed state or simply remove it. if (remove_lease) { lease_mgr.deleteLease(lease); - } else if (!lease_update_fun.empty()) { + } else if (lease_update_fun) { // Clear FQDN information as we have already sent the // name change request to remove the DNS record. lease->hostname_.clear(); diff --git a/src/lib/dhcpsrv/alloc_engine.h b/src/lib/dhcpsrv/alloc_engine.h index 54816a5a94..43f6ca4b68 100644 --- a/src/lib/dhcpsrv/alloc_engine.h +++ b/src/lib/dhcpsrv/alloc_engine.h @@ -25,10 +25,10 @@ #include #include -#include #include #include +#include #include #include #include @@ -1268,7 +1268,7 @@ private: template void reclaimLeaseInDatabase(const LeasePtrType& lease, const bool remove_lease, - const boost::function& + const std::function& lease_update_fun) const; /// @anchor reclaimDeclinedLease4 diff --git a/src/lib/dhcpsrv/cfg_expiration.h b/src/lib/dhcpsrv/cfg_expiration.h index de13d485c7..76d1b4514b 100644 --- a/src/lib/dhcpsrv/cfg_expiration.h +++ b/src/lib/dhcpsrv/cfg_expiration.h @@ -1,4 +1,4 @@ -// Copyright (C) 2015,2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include @@ -303,11 +303,11 @@ CfgExpiration::setupTimers(void (Instance::*reclaim_fun)(const size_t, 1000 * getReclaimTimerWaitTime(); // Register timer for leases' reclamation routine. timer_mgr_->registerTimer(RECLAIM_EXPIRED_TIMER_NAME, - boost::bind(reclaim_fun, instance_ptr, - getMaxReclaimLeases(), - getMaxReclaimTime(), - flush_timer_disabled, - getUnwarnedReclaimCycles()), + std::bind(reclaim_fun, instance_ptr, + getMaxReclaimLeases(), + getMaxReclaimTime(), + flush_timer_disabled, + getUnwarnedReclaimCycles()), reclaim_interval, asiolink::IntervalTimer::ONE_SHOT); timer_mgr_->setup(RECLAIM_EXPIRED_TIMER_NAME); @@ -323,8 +323,8 @@ CfgExpiration::setupTimers(void (Instance::*reclaim_fun)(const size_t, 1000 * getFlushReclaimedTimerWaitTime(); // Register and setup the timer. timer_mgr_->registerTimer(FLUSH_RECLAIMED_TIMER_NAME, - boost::bind(delete_fun, instance_ptr, - getHoldReclaimedTime()), + std::bind(delete_fun, instance_ptr, + getHoldReclaimedTime()), flush_interval, asiolink::IntervalTimer::ONE_SHOT); timer_mgr_->setup(FLUSH_RECLAIMED_TIMER_NAME); diff --git a/src/lib/dhcpsrv/cfg_iface.cc b/src/lib/dhcpsrv/cfg_iface.cc index ea137ca041..68a2f0e868 100644 --- a/src/lib/dhcpsrv/cfg_iface.cc +++ b/src/lib/dhcpsrv/cfg_iface.cc @@ -9,11 +9,12 @@ #include #include #include -#include #include +#include using namespace isc::asiolink; using namespace isc::data; +using namespace std::placeholders; namespace isc { namespace dhcp { @@ -151,7 +152,7 @@ CfgIface::openSockets(const uint16_t family, const uint16_t port, // for some specific interface. This callback will simply log a // warning message. IfaceMgrErrorMsgCallback error_callback = - boost::bind(&CfgIface::socketOpenErrorHandler, _1); + std::bind(&CfgIface::socketOpenErrorHandler, _1); bool sopen; if (family == AF_INET) { // Use broadcast only if we're using raw sockets. For the UDP sockets, diff --git a/src/lib/dhcpsrv/d2_client_mgr.cc b/src/lib/dhcpsrv/d2_client_mgr.cc index b365c78b1b..6671471309 100644 --- a/src/lib/dhcpsrv/d2_client_mgr.cc +++ b/src/lib/dhcpsrv/d2_client_mgr.cc @@ -11,8 +11,7 @@ #include #include -#include - +#include #include using namespace std; @@ -259,8 +258,8 @@ D2ClientMgr::startSender(D2ClientErrorHandler error_handler, // IO error handling in the sender may alter its select-fd. registered_select_fd_ = name_change_sender_->getSelectFd(); IfaceMgr::instance().addExternalSocket(registered_select_fd_, - boost::bind(&D2ClientMgr::runReadyIO, - this)); + std::bind(&D2ClientMgr::runReadyIO, + this)); } bool diff --git a/src/lib/dhcpsrv/d2_client_mgr.h b/src/lib/dhcpsrv/d2_client_mgr.h index 273c8bdbd6..4500e2b319 100644 --- a/src/lib/dhcpsrv/d2_client_mgr.h +++ b/src/lib/dhcpsrv/d2_client_mgr.h @@ -40,8 +40,8 @@ namespace dhcp { /// @note Handlers are expected not to throw. In the event a handler does /// throw invoking code logs the exception and then swallows it. typedef -boost::function D2ClientErrorHandler; +std::function D2ClientErrorHandler; /// @brief D2ClientMgr isolates Kea from the details of being a D2 client. /// @@ -375,7 +375,7 @@ public: /// /// Serves as callback registered for the sender's select-fd with IfaceMgr. /// It instructs the sender to execute the next ready IO handler. - /// It provides an instance method that can be bound via boost::bind, as + /// It provides an instance method that can be bound via std::bind, as /// NameChangeSender is abstract. void runReadyIO(); diff --git a/src/lib/dhcpsrv/host_data_source_factory.h b/src/lib/dhcpsrv/host_data_source_factory.h index 113f5f944d..b39ad954e4 100644 --- a/src/lib/dhcpsrv/host_data_source_factory.h +++ b/src/lib/dhcpsrv/host_data_source_factory.h @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,8 +11,8 @@ #include #include #include -#include +#include #include #include #include @@ -79,7 +79,7 @@ public: /// /// A factory takes a parameter map and returns a pointer to a host /// data source. In case of failure it must throw and not return NULL. - typedef boost::function Factory; + typedef std::function Factory; /// @brief Register a host data source factory /// diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc index 7272baa00a..801d4fe82f 100644 --- a/src/lib/dhcpsrv/memfile_lease_mgr.cc +++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc @@ -1864,7 +1864,7 @@ Memfile_LeaseMgr::lfcSetup(bool conversion_needed) { } if (lfc_interval > 0 || conversion_needed) { - lfc_setup_.reset(new LFCSetup(boost::bind(&Memfile_LeaseMgr::lfcCallback, this))); + lfc_setup_.reset(new LFCSetup(std::bind(&Memfile_LeaseMgr::lfcCallback, this))); lfc_setup_->setup(lfc_interval, lease_file4_, lease_file6_, conversion_needed); } } diff --git a/src/lib/dhcpsrv/network_state.cc b/src/lib/dhcpsrv/network_state.cc index 16dbe2ba0b..a86a3465b5 100644 --- a/src/lib/dhcpsrv/network_state.cc +++ b/src/lib/dhcpsrv/network_state.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include #include namespace { @@ -65,8 +65,8 @@ public: void createTimer(const unsigned int seconds) { destroyTimer(); timer_mgr_->registerTimer(NETWORK_STATE_TIMER_NAME, - boost::bind(&NetworkStateImpl::enableAll, - shared_from_this()), + std::bind(&NetworkStateImpl::enableAll, + shared_from_this()), seconds * 1000, asiolink::IntervalTimer::ONE_SHOT); timer_mgr_->setup(NETWORK_STATE_TIMER_NAME); diff --git a/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc index bcb5526b95..c3b4828afc 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc @@ -13,9 +13,8 @@ #include #include #include -#include -#include #include +#include #include #include #include @@ -23,6 +22,7 @@ #include using namespace std; +using namespace std::placeholders; using namespace isc; using namespace isc::asiolink; using namespace isc::dhcp; @@ -160,9 +160,9 @@ class ExpirationAllocEngineTest : public ::testing::Test { public: /// @brief Type definition for the lease algorithm. - typedef boost::function LeaseAlgorithmFun; + typedef std::function LeaseAlgorithmFun; /// @brief type definition for the lease index algorithm. - typedef boost::function IndexAlgorithmFun; + typedef std::function IndexAlgorithmFun; /// @brief Constructor. /// @@ -232,7 +232,7 @@ public: D2ClientConfigPtr cfg(new D2ClientConfig()); cfg->enableUpdates(true); mgr.setD2ClientConfig(cfg); - mgr.startSender(boost::bind(&ExpirationAllocEngineTest::d2ErrorHandler, _1, _2)); + mgr.startSender(std::bind(&ExpirationAllocEngineTest::d2ErrorHandler, _1, _2)); } /// @brief No-op error handler for the D2 client. diff --git a/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc b/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc index 53468cd99a..7567802a89 100644 --- a/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_expiration_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015,2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,9 +11,9 @@ #include #include #include -#include #include #include +#include #include using namespace isc; @@ -23,13 +23,13 @@ using namespace isc::dhcp; namespace { /// @brief Type definition of the @c CfgExpiration modified function. -typedef boost::function ModifierFun; +typedef std::function ModifierFun; /// @brief Type definition of the @c CfgExpiration accessor function /// returning uint16_t value. -typedef boost::function AccessorFunUint16; +typedef std::function AccessorFunUint16; /// @brief Type definition of the @c CfgExpiration accessor function /// returning uint32_t value. -typedef boost::function AccessorFunUint32; +typedef std::function AccessorFunUint32; /// @brief Tests the accessor and modifier function for a particular /// configuration parameter held in @c CfgExpiration. @@ -50,7 +50,7 @@ typedef boost::function AccessorFunUint32; template void testAccessModify(const int64_t limit, const ModifierFun& modifier, - const boost::function& accessor) { + const std::function& accessor) { CfgExpiration cfg; // Setting the value to maximum allowed + 1 should result in diff --git a/src/lib/dhcpsrv/tests/d2_udp_unittest.cc b/src/lib/dhcpsrv/tests/d2_udp_unittest.cc index 28139d14c4..47b96f5797 100644 --- a/src/lib/dhcpsrv/tests/d2_udp_unittest.cc +++ b/src/lib/dhcpsrv/tests/d2_udp_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,13 +15,13 @@ #include #include -#include -#include #include +#include #include using namespace std; +using namespace std::placeholders; using namespace isc::dhcp; using namespace isc; @@ -165,7 +165,7 @@ public: /// @brief Returns D2ClientErroHandler bound to this::error_handler_. D2ClientErrorHandler getErrorHandler() { - return (boost::bind(&D2ClientMgrTest::error_handler, this, _1, _2)); + return (std::bind(&D2ClientMgrTest::error_handler, this, _1, _2)); } /// @brief Constructs a NameChangeRequest message from a fixed JSON string. diff --git a/src/lib/dhcpsrv/tests/dhcp4o6_ipc_unittest.cc b/src/lib/dhcpsrv/tests/dhcp4o6_ipc_unittest.cc index 8818bd53b0..e3c9d010f6 100644 --- a/src/lib/dhcpsrv/tests/dhcp4o6_ipc_unittest.cc +++ b/src/lib/dhcpsrv/tests/dhcp4o6_ipc_unittest.cc @@ -15,9 +15,8 @@ #include #include #include -#include -#include #include +#include #include #include @@ -35,7 +34,7 @@ const uint16_t TEST_PORT = 12345; const uint16_t TEST_ITERATIONS = 10; /// @brief Type definition for the function creating DHCP message. -typedef boost::function CreateMsgFun; +typedef std::function CreateMsgFun; /// @brief Define short name for test IPC class. typedef Dhcp4o6TestIpc TestIpc; diff --git a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc index d5228e07b3..fc2db6f4c1 100644 --- a/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc @@ -26,6 +26,7 @@ #include using namespace std; +using namespace std::placeholders; using namespace isc::asiolink; using namespace isc::data; using namespace isc::db; @@ -3284,7 +3285,7 @@ LeaseMgrDbLostCallbackTest::TearDown() { void LeaseMgrDbLostCallbackTest::testNoCallbackOnOpenFailure() { DatabaseConnection::db_lost_callback = - boost::bind(&LeaseMgrDbLostCallbackTest::db_lost_callback, this, _1); + std::bind(&LeaseMgrDbLostCallbackTest::db_lost_callback, this, _1); callback_called_ = false; ASSERT_THROW(LeaseMgrFactory::create(invalidConnectString()), @@ -3297,7 +3298,7 @@ void LeaseMgrDbLostCallbackTest::testDbLostCallback() { // Set the connectivity lost callback. DatabaseConnection::db_lost_callback = - boost::bind(&LeaseMgrDbLostCallbackTest::db_lost_callback, this, _1); + std::bind(&LeaseMgrDbLostCallbackTest::db_lost_callback, this, _1); // Connect to the lease backend. ASSERT_NO_THROW(LeaseMgrFactory::create(validConnectString())); diff --git a/src/lib/dhcpsrv/tests/host_mgr_unittest.cc b/src/lib/dhcpsrv/tests/host_mgr_unittest.cc index 6798af604f..bcb67ac144 100644 --- a/src/lib/dhcpsrv/tests/host_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/host_mgr_unittest.cc @@ -33,6 +33,7 @@ using namespace isc::db; using namespace isc::dhcp; using namespace isc::dhcp::test; using namespace isc::asiolink; +using namespace std::placeholders; namespace { @@ -1131,7 +1132,7 @@ HostMgrDbLostCallbackTest::testDbLostCallback() { // Set the connectivity lost callback. DatabaseConnection::db_lost_callback = - boost::bind(&HostMgrDbLostCallbackTest::db_lost_callback, this, _1); + std::bind(&HostMgrDbLostCallbackTest::db_lost_callback, this, _1); // Find the most recently opened socket. Our SQL client's socket should // be the next one. diff --git a/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc b/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc index b44aba1a30..06f956e6e0 100644 --- a/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc +++ b/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc @@ -13,10 +13,9 @@ #include #include -#include -#include #include - +#include +#include #include #include @@ -24,6 +23,7 @@ using namespace isc; using namespace isc::asiolink; using namespace isc::dhcp; using namespace isc::dhcp_ddns; +using namespace std::placeholders; namespace { @@ -81,8 +81,8 @@ public: D2ClientConfigPtr cfg(new D2ClientConfig()); ASSERT_NO_THROW(cfg->enableUpdates(true)); ASSERT_NO_THROW(CfgMgr::instance().setD2ClientConfig(cfg)); - d2_mgr_.startSender(boost::bind(&NCRGeneratorTest::d2ErrorHandler, this, - _1, _2)); + d2_mgr_.startSender(std::bind(&NCRGeneratorTest::d2ErrorHandler, this, + _1, _2)); } /// @brief Disables DHCP-DDNS updates. diff --git a/src/lib/dhcpsrv/tests/network_state_unittest.cc b/src/lib/dhcpsrv/tests/network_state_unittest.cc index 30933adc7e..879ead17d1 100644 --- a/src/lib/dhcpsrv/tests/network_state_unittest.cc +++ b/src/lib/dhcpsrv/tests/network_state_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include using namespace isc; using namespace isc::asiolink; @@ -51,7 +51,9 @@ public: /// /// @param timeout_ms Timeout for running IO service in milliseconds. void runIOService(const long timeout_ms) { - test_timer_.setup(boost::bind(&NetworkStateTest::testTimerCallback, this), timeout_ms, + test_timer_.setup(std::bind(&NetworkStateTest::testTimerCallback, + this), + timeout_ms, IntervalTimer::ONE_SHOT); io_service_->run(); } diff --git a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc index b6e6e94017..bdcc27684d 100644 --- a/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/timer_mgr_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,9 +11,9 @@ #include #include -#include #include +#include #include #include @@ -73,10 +73,10 @@ public: /// /// This is just a wrapped to make it a bit more convenient /// in the test. - boost::function makeCallback(const std::string& timer_name); + std::function makeCallback(const std::string& timer_name); /// @brief Create a callback which generates exception. - boost::function makeCallbackWithException(); + std::function makeCallbackWithException(); /// @brief Callback for timeout. /// @@ -154,14 +154,14 @@ TimerMgrTest::timerCallbackWithException() { isc_throw(Exception, "timerCallbackWithException"); } -boost::function +std::function TimerMgrTest::makeCallback(const std::string& timer_name) { - return (boost::bind(&TimerMgrTest::timerCallback, this, timer_name)); + return (std::bind(&TimerMgrTest::timerCallback, this, timer_name)); } -boost::function +std::function TimerMgrTest::makeCallbackWithException() { - return (boost::bind(&TimerMgrTest::timerCallbackWithException, this)); + return (std::bind(&TimerMgrTest::timerCallbackWithException, this)); } // This test checks that certain errors are returned when invalid diff --git a/src/lib/dhcpsrv/testutils/dhcp4o6_test_ipc.cc b/src/lib/dhcpsrv/testutils/dhcp4o6_test_ipc.cc index 36a37efb48..a50a5c2e7c 100644 --- a/src/lib/dhcpsrv/testutils/dhcp4o6_test_ipc.cc +++ b/src/lib/dhcpsrv/testutils/dhcp4o6_test_ipc.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,7 +7,7 @@ #include #include #include -#include +#include namespace isc { namespace dhcp { @@ -27,7 +27,7 @@ Dhcp4o6TestIpc::open() { if (socket_fd_ != -1) { IfaceMgr& iface_mgr = IfaceMgr::instance(); iface_mgr.addExternalSocket(socket_fd_, - boost::bind(&Dhcp4o6TestIpc::receiveHandler, this)); + std::bind(&Dhcp4o6TestIpc::receiveHandler, this)); } } diff --git a/src/lib/dhcpsrv/timer_mgr.cc b/src/lib/dhcpsrv/timer_mgr.cc index 899116bf8b..c3eed89f87 100644 --- a/src/lib/dhcpsrv/timer_mgr.cc +++ b/src/lib/dhcpsrv/timer_mgr.cc @@ -11,8 +11,7 @@ #include #include -#include - +#include #include using namespace isc; @@ -263,8 +262,8 @@ TimerMgrImpl::setup(const std::string& timer_name) { // Schedule the execution of the timer using the parameters supplied // during the registration. const TimerInfoPtr& timer_info = timer_info_it->second; - IntervalTimer::Callback cb = boost::bind(&TimerMgrImpl::timerCallback, this, - timer_name); + IntervalTimer::Callback cb = std::bind(&TimerMgrImpl::timerCallback, this, + timer_name); timer_info->interval_timer_.setup(cb, timer_info->interval_, timer_info->scheduling_mode_); } diff --git a/src/lib/dns/master_loader.cc b/src/lib/dns/master_loader.cc index b664f3d350..568fdea507 100644 --- a/src/lib/dns/master_loader.cc +++ b/src/lib/dns/master_loader.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -1019,7 +1019,7 @@ MasterLoader::MasterLoader(const char* master_file, const AddRRCallback& add_callback, Options options) { - if (add_callback.empty()) { + if (!add_callback) { isc_throw(isc::InvalidParameter, "Empty add RR callback"); } impl_ = new MasterLoaderImpl(master_file, zone_origin, @@ -1033,7 +1033,7 @@ MasterLoader::MasterLoader(std::istream& stream, const AddRRCallback& add_callback, Options options) { - if (add_callback.empty()) { + if (!add_callback) { isc_throw(isc::InvalidParameter, "Empty add RR callback"); } unique_ptr diff --git a/src/lib/dns/master_loader_callbacks.h b/src/lib/dns/master_loader_callbacks.h index 1b53179028..b5637414e5 100644 --- a/src/lib/dns/master_loader_callbacks.h +++ b/src/lib/dns/master_loader_callbacks.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,9 +9,9 @@ #include -#include -#include #include +#include +#include namespace isc { namespace dns { @@ -35,9 +35,9 @@ typedef boost::shared_ptr RdataPtr; /// \param rrtype Type of the RR. /// \param rrttl Time to live of the RR. /// \param rdata The actual carried data of the RR. -typedef boost::function +typedef std::function AddRRCallback; /// \brief Set of issue callbacks for a loader. @@ -58,9 +58,9 @@ public: /// \param source_line Position of the problem, counted in lines from the /// beginning of the source. /// \param reason Human readable description of what happened. - typedef boost::function IssueCallback; + typedef std::function IssueCallback; /// \brief Constructor /// @@ -74,7 +74,7 @@ public: error_(error), warning_(warning) { - if (error_.empty() || warning_.empty()) { + if (!error_ || !warning) { isc_throw(isc::InvalidParameter, "Empty function passed as callback"); } diff --git a/src/lib/dns/masterload.cc b/src/lib/dns/masterload.cc index bbb9597272..ef32ea2dae 100644 --- a/src/lib/dns/masterload.cc +++ b/src/lib/dns/masterload.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -6,18 +6,6 @@ #include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - #include #include #include @@ -28,9 +16,19 @@ #include #include #include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include using namespace std; -using namespace boost; using namespace isc::dns::rdata; namespace isc { @@ -64,8 +62,8 @@ void loadHelper(InputType input, const Name& origin, const RRClass& zone_class, MasterLoadCallback callback) { - RRCollator rr_collator(boost::bind(callbackWrapper, _1, - callback, &origin)); + RRCollator rr_collator(std::bind(callbackWrapper, std::placeholders::_1, + callback, &origin)); MasterLoader loader(input, origin, zone_class, MasterLoaderCallbacks::getNullCallbacks(), rr_collator.getCallback()); diff --git a/src/lib/dns/masterload.h b/src/lib/dns/masterload.h index 30b0fa1d42..3762d54e47 100644 --- a/src/lib/dns/masterload.h +++ b/src/lib/dns/masterload.h @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,13 +7,11 @@ #ifndef MASTERLOAD_H #define MASTERLOAD_H 1 -#include - -#include - +#include #include -#include +#include +#include namespace isc { namespace dns { @@ -32,7 +30,7 @@ public: /// /// This represents a functor object or a function that takes one parameter /// of type \c RRsetPtr and returns nothing. -typedef boost::function MasterLoadCallback; +typedef std::function MasterLoadCallback; /// /// \name Master zone file loader functions. @@ -48,7 +46,7 @@ typedef boost::function MasterLoadCallback; /// The \c callback parameter is a functor object or a function that /// takes one parameter of type \c RRsetPtr and returns nothing, /// i.e. \c void (see below for specific examples). -/// More precisely, it can be anything that this form of boost::function +/// More precisely, it can be anything that this form of std::function /// can represent, but the caller normally doesn't have to care about /// that level of details. /// @@ -104,7 +102,7 @@ typedef boost::function MasterLoadCallback; /// masterLoad(zone_file, Name("example.com"), RRClass::IN(), zoneDumper); /// \endcode /// Or, if you want to use it with a member function of some other class, -/// wrapping things with \c boost::bind would be handy: +/// wrapping things with \c std::bind would be handy: /// \code class ZoneDumper { /// public: /// void dump(ConstRRsetPtr rrset) const { @@ -114,7 +112,7 @@ typedef boost::function MasterLoadCallback; /// ... /// ZoneDumper dumper; /// masterLoad(rr_stream, Name("example.com"), RRClass::IN(), -/// boost::bind(&ZoneDumper::dump, &dumper, _1)); +/// std::bind(&ZoneDumper::dump, &dumper, _1)); /// \endcode /// You can find a bit more complicated examples in the unit tests code for /// this function. diff --git a/src/lib/dns/rrcollator.cc b/src/lib/dns/rrcollator.cc index e2fa0e4460..8d90b23bc6 100644 --- a/src/lib/dns/rrcollator.cc +++ b/src/lib/dns/rrcollator.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,9 +19,8 @@ #include #include -#include - #include +#include namespace isc { namespace dns { @@ -88,8 +87,9 @@ RRCollator::~RRCollator() { AddRRCallback RRCollator::getCallback() { - return (boost::bind(&RRCollator::Impl::addRR, this->impl_, - _1, _2, _3, _4, _5)); + using namespace std::placeholders; + return (std::bind(&RRCollator::Impl::addRR, this->impl_, + _1, _2, _3, _4, _5)); } void diff --git a/src/lib/dns/rrcollator.h b/src/lib/dns/rrcollator.h index 6ada41ed9e..9442fd3970 100644 --- a/src/lib/dns/rrcollator.h +++ b/src/lib/dns/rrcollator.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,7 +11,7 @@ #include #include -#include +#include namespace isc { namespace dns { @@ -51,7 +51,7 @@ public: /// the \c RRCollator. /// /// \param rrset The collated RRset. - typedef boost::function AddRRsetCallback; + typedef std::function AddRRsetCallback; /// \brief Constructor. /// diff --git a/src/lib/dns/rrset_collection.cc b/src/lib/dns/rrset_collection.cc index 54503044b0..6760e07b22 100644 --- a/src/lib/dns/rrset_collection.cc +++ b/src/lib/dns/rrset_collection.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,7 +13,7 @@ #include -#include +#include using namespace isc; @@ -45,10 +45,11 @@ void RRsetCollection::constructHelper(T source, const isc::dns::Name& origin, const isc::dns::RRClass& rrclass) { - RRCollator collator(boost::bind(&RRsetCollection::addRRset, this, _1)); + using namespace std::placeholders; + RRCollator collator(std::bind(&RRsetCollection::addRRset, this, _1)); MasterLoaderCallbacks callbacks - (boost::bind(&RRsetCollection::loaderCallback, this, _1, _2, _3), - boost::bind(&RRsetCollection::loaderCallback, this, _1, _2, _3)); + (std::bind(&RRsetCollection::loaderCallback, this, _1, _2, _3), + std::bind(&RRsetCollection::loaderCallback, this, _1, _2, _3)); MasterLoader loader(source, origin, rrclass, callbacks, collator.getCallback(), MasterLoader::DEFAULT); diff --git a/src/lib/dns/tests/master_loader_callbacks_test.cc b/src/lib/dns/tests/master_loader_callbacks_test.cc index e66f92857b..977e19b725 100644 --- a/src/lib/dns/tests/master_loader_callbacks_test.cc +++ b/src/lib/dns/tests/master_loader_callbacks_test.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,12 +15,13 @@ #include #include -#include +#include namespace { using std::string; using namespace isc::dns; + using namespace std::placeholders; class MasterLoaderCallbacksTest : public ::testing::Test { protected: @@ -29,10 +30,10 @@ protected: issue_called_(false), rrset_(new RRset(Name("example.org"), RRClass::IN(), RRType::A(), RRTTL(3600))), - error_(boost::bind(&MasterLoaderCallbacksTest::checkCallback, this, - true, _1, _2, _3)), - warning_(boost::bind(&MasterLoaderCallbacksTest::checkCallback, this, - false, _1, _2, _3)), + error_(std::bind(&MasterLoaderCallbacksTest::checkCallback, this, + true, _1, _2, _3)), + warning_(std::bind(&MasterLoaderCallbacksTest::checkCallback, this, + false, _1, _2, _3)), callbacks_(error_, warning_) {} diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc index 6a7f95a1c9..57f6e0ca83 100644 --- a/src/lib/dns/tests/master_loader_unittest.cc +++ b/src/lib/dns/tests/master_loader_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -17,16 +17,17 @@ #include -#include #include #include +#include #include #include #include #include using namespace isc::dns; +using namespace std::placeholders; using std::vector; using std::string; using std::list; @@ -38,10 +39,10 @@ namespace { class MasterLoaderTest : public ::testing::Test { public: MasterLoaderTest() : - callbacks_(boost::bind(&MasterLoaderTest::callback, this, - &errors_, _1, _2, _3), - boost::bind(&MasterLoaderTest::callback, this, - &warnings_, _1, _2, _3)) + callbacks_(std::bind(&MasterLoaderTest::callback, this, + &errors_, _1, _2, _3), + std::bind(&MasterLoaderTest::callback, this, + &warnings_, _1, _2, _3)) {} void TearDown() { @@ -71,8 +72,8 @@ public: const RRClass& rrclass, const MasterLoader::Options options) { loader_.reset(new MasterLoader(file, origin, rrclass, callbacks_, - boost::bind(&MasterLoaderTest::addRRset, - this, _1, _2, _3, _4, _5), + std::bind(&MasterLoaderTest::addRRset, + this, _1, _2, _3, _4, _5), options)); } @@ -80,8 +81,8 @@ public: const RRClass& rrclass, const MasterLoader::Options options) { loader_.reset(new MasterLoader(stream, origin, rrclass, callbacks_, - boost::bind(&MasterLoaderTest::addRRset, - this, _1, _2, _3, _4, _5), + std::bind(&MasterLoaderTest::addRRset, + this, _1, _2, _3, _4, _5), options)); } diff --git a/src/lib/dns/tests/masterload_unittest.cc b/src/lib/dns/tests/masterload_unittest.cc index 90c6a27591..52fc989e61 100644 --- a/src/lib/dns/tests/masterload_unittest.cc +++ b/src/lib/dns/tests/masterload_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -13,8 +13,6 @@ #include #include -#include - #include #include @@ -24,6 +22,7 @@ #include using namespace std; +using namespace std::placeholders; using namespace isc::dns; namespace { @@ -95,7 +94,7 @@ TEST_F(MasterLoadTest, loadWithFunctionCallback) { // object) rr_stream << txt_rr << a_rr1 << soa_rr; masterLoad(rr_stream, origin, zclass, - boost::bind(&testCallback, _1, &results)); + std::bind(&testCallback, _1, &results)); ASSERT_EQ(3, results.size()); EXPECT_EQ(txt_rr, results[0]->toText()); EXPECT_EQ(a_rr1, results[1]->toText()); @@ -104,10 +103,10 @@ TEST_F(MasterLoadTest, loadWithFunctionCallback) { TEST_F(MasterLoadTest, loadWithMemFunctionCallback) { // The same test as loadRRs but using a class member function (with a - // help of Boost.bind) + // help of std.bind) rr_stream << txt_rr << a_rr1 << soa_rr; masterLoad(rr_stream, origin, zclass, - boost::bind(&MasterLoadTest::rrsetCallback, this, _1)); + std::bind(&MasterLoadTest::rrsetCallback, this, _1)); ASSERT_EQ(3, results.size()); EXPECT_EQ(txt_rr, results[0]->toText()); EXPECT_EQ(a_rr1, results[1]->toText()); diff --git a/src/lib/dns/tests/rdata_unittest.cc b/src/lib/dns/tests/rdata_unittest.cc index 83d980505f..e774ddea81 100644 --- a/src/lib/dns/tests/rdata_unittest.cc +++ b/src/lib/dns/tests/rdata_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2010-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -6,6 +6,7 @@ #include +#include #include #include #include @@ -24,10 +25,10 @@ #include -#include #include using namespace std; +using namespace std::placeholders; using namespace isc::dns; using namespace isc::util; using namespace isc::dns::rdata; @@ -135,10 +136,10 @@ TEST_F(RdataTest, createRdataWithLexer) { CreateRdataCallback callback; MasterLoaderCallbacks callbacks( - boost::bind(&CreateRdataCallback::callback, &callback, - CreateRdataCallback::ERROR, _1, _2, _3), - boost::bind(&CreateRdataCallback::callback, &callback, - CreateRdataCallback::WARN, _1, _2, _3)); + std::bind(&CreateRdataCallback::callback, &callback, + CreateRdataCallback::ERROR, _1, _2, _3), + std::bind(&CreateRdataCallback::callback, &callback, + CreateRdataCallback::WARN, _1, _2, _3)); size_t line = 0; diff --git a/src/lib/dns/tests/rrcollator_unittest.cc b/src/lib/dns/tests/rrcollator_unittest.cc index 3bd1696b61..bb3618f4d5 100644 --- a/src/lib/dns/tests/rrcollator_unittest.cc +++ b/src/lib/dns/tests/rrcollator_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,14 +19,14 @@ #include -#include - +#include #include #include using std::vector; using namespace isc::dns; using namespace isc::dns::rdata; +using namespace std::placeholders; namespace { @@ -46,7 +46,7 @@ protected: RRCollatorTest() : origin_("example.com"), rrclass_(RRClass::IN()), rrttl_(3600), throw_from_callback_(false), - collator_(boost::bind(addRRset, _1, &rrsets_, &throw_from_callback_)), + collator_(std::bind(addRRset, _1, &rrsets_, &throw_from_callback_)), rr_callback_(collator_.getCallback()), a_rdata1_(createRdata(RRType::A(), rrclass_, "192.0.2.1")), a_rdata2_(createRdata(RRType::A(), rrclass_, "192.0.2.2")), diff --git a/src/lib/dns/tests/zone_checker_unittest.cc b/src/lib/dns/tests/zone_checker_unittest.cc index 3a9809f5aa..d2f5a41344 100644 --- a/src/lib/dns/tests/zone_checker_unittest.cc +++ b/src/lib/dns/tests/zone_checker_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015,2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -20,10 +20,10 @@ #include -#include #include #include +#include #include #include #include @@ -31,6 +31,7 @@ using isc::Unexpected; using namespace isc::dns; using namespace isc::dns::rdata; +using namespace std::placeholders; namespace { @@ -46,8 +47,8 @@ protected: zname_("example.com"), zclass_(RRClass::IN()), soa_(new RRset(zname_, zclass_, RRType::SOA(), RRTTL(60))), ns_(new RRset(zname_, zclass_, RRType::NS(), RRTTL(60))), - callbacks_(boost::bind(&ZoneCheckerTest::callback, this, _1, true), - boost::bind(&ZoneCheckerTest::callback, this, _1, false)) + callbacks_(std::bind(&ZoneCheckerTest::callback, this, _1, true), + std::bind(&ZoneCheckerTest::callback, this, _1, false)) { std::stringstream ss; ss << "example.com. 60 IN SOA " << soa_txt << "\n"; @@ -58,7 +59,7 @@ protected: } public: - // This one is passed to boost::bind. Some compilers seem to require + // This one is passed to std::bind. Some compilers seem to require // it be public. void callback(const std::string& reason, bool is_error) { if (is_error) { @@ -132,7 +133,7 @@ TEST_F(ZoneCheckerTest, checkSOA) { // If null callback is specified, checkZone() only returns the final // result. ZoneCheckerCallbacks noerror_callbacks( - 0, boost::bind(&ZoneCheckerTest::callback, this, _1, false)); + 0, std::bind(&ZoneCheckerTest::callback, this, _1, false)); EXPECT_FALSE(checkZone(zname_, zclass_, *rrsets_, noerror_callbacks)); checkIssues(); @@ -196,7 +197,7 @@ TEST_F(ZoneCheckerTest, checkNSData) { // Same check, but disabling warning callback. Same result, but without // the warning. ZoneCheckerCallbacks nowarn_callbacks( - boost::bind(&ZoneCheckerTest::callback, this, _1, true), 0); + std::bind(&ZoneCheckerTest::callback, this, _1, true), 0); EXPECT_TRUE(checkZone(zname_, zclass_, *rrsets_, nowarn_callbacks)); checkIssues(); diff --git a/src/lib/dns/zone_checker.cc b/src/lib/dns/zone_checker.cc index 3447a00d9b..7fe81726a8 100644 --- a/src/lib/dns/zone_checker.cc +++ b/src/lib/dns/zone_checker.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,9 +15,9 @@ #include #include -#include #include +#include #include using boost::lexical_cast; @@ -175,10 +175,11 @@ bool checkZone(const Name& zone_name, const RRClass& zone_class, const RRsetCollectionBase& zone_rrsets, const ZoneCheckerCallbacks& callbacks) { + using namespace std::placeholders; bool had_error = false; ZoneCheckerCallbacks my_callbacks( - boost::bind(errorWrapper, _1, &callbacks, &had_error), - boost::bind(&ZoneCheckerCallbacks::warn, &callbacks, _1)); + std::bind(errorWrapper, _1, &callbacks, &had_error), + std::bind(&ZoneCheckerCallbacks::warn, &callbacks, _1)); checkSOA(zone_name, zone_class, zone_rrsets, my_callbacks); checkNS(zone_name, zone_class, zone_rrsets, my_callbacks); diff --git a/src/lib/dns/zone_checker.h b/src/lib/dns/zone_checker.h index f0a057d1be..be36a32417 100644 --- a/src/lib/dns/zone_checker.h +++ b/src/lib/dns/zone_checker.h @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,8 +9,7 @@ #include -#include - +#include #include namespace isc { @@ -24,7 +23,7 @@ public: /// \brief Functor type of the callback on some issue (error or warning). /// /// Its parameter indicates the reason for the corresponding issue. - typedef boost::function IssueCallback; + typedef std::function IssueCallback; /// \brief Constructor. /// @@ -52,7 +51,7 @@ public: /// /// \param reason Textual representation of the reason for the error. void error(const std::string& reason) const { - if (!error_callback_.empty()) { + if (error_callback_) { error_callback_(reason); } } @@ -64,7 +63,7 @@ public: /// /// \param reason Textual representation of the reason for the issue. void warn(const std::string& reason) const { - if (!warn_callback_.empty()) + if (warn_callback_) warn_callback_(reason); } diff --git a/src/lib/http/client.cc b/src/lib/http/client.cc index 3f0af351f0..bf1acc59e7 100644 --- a/src/lib/http/client.cc +++ b/src/lib/http/client.cc @@ -17,12 +17,12 @@ #include #include -#include #include #include #include #include +#include #include #include #include @@ -41,7 +41,7 @@ namespace { constexpr size_t MAX_LOGGED_MESSAGE_SIZE = 1024; /// @brief TCP socket callback function type. -typedef boost::function +typedef std::function SocketCallbackFunction; /// @brief Socket callback class required by the TCPSocket API. @@ -831,8 +831,9 @@ Connection::doTransactionInternal(const HttpRequestPtr& request, /// over for names. TCPEndpoint endpoint(url_.getStrippedHostname(), static_cast(url_.getPort())); - SocketCallback socket_cb(boost::bind(&Connection::connectCallback, shared_from_this(), - connect_callback, current_transid_, _1)); + SocketCallback socket_cb(std::bind(&Connection::connectCallback, shared_from_this(), + connect_callback, current_transid_, + std::placeholders::_1)); // Establish new connection or use existing connection. socket_.open(&endpoint, socket_cb); @@ -991,15 +992,18 @@ Connection::terminateInternal(const boost::system::error_code& ec, void Connection::scheduleTimer(const long request_timeout) { if (request_timeout > 0) { - timer_.setup(boost::bind(&Connection::timerCallback, this), request_timeout, + timer_.setup(std::bind(&Connection::timerCallback, this), request_timeout, IntervalTimer::ONE_SHOT); } } void Connection::doSend(const uint64_t transid) { - SocketCallback socket_cb(boost::bind(&Connection::sendCallback, shared_from_this(), - transid, _1, _2)); + SocketCallback socket_cb(std::bind(&Connection::sendCallback, + shared_from_this(), + transid, + std::placeholders::_1, + std::placeholders::_2)); try { socket_.asyncSend(&buf_[0], buf_.size(), socket_cb); @@ -1011,8 +1015,11 @@ Connection::doSend(const uint64_t transid) { void Connection::doReceive(const uint64_t transid) { TCPEndpoint endpoint; - SocketCallback socket_cb(boost::bind(&Connection::receiveCallback, shared_from_this(), - transid, _1, _2)); + SocketCallback socket_cb(std::bind(&Connection::receiveCallback, + shared_from_this(), + transid, + std::placeholders::_1, + std::placeholders::_2)); try { socket_.asyncReceive(static_cast(input_buf_.data()), input_buf_.size(), 0, diff --git a/src/lib/http/connection.cc b/src/lib/http/connection.cc index d3d117a049..f2dbfd8f3e 100644 --- a/src/lib/http/connection.cc +++ b/src/lib/http/connection.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,8 +11,8 @@ #include #include #include -#include #include +#include using namespace isc::asiolink; @@ -105,9 +105,9 @@ HttpConnection::asyncAccept() { // Create instance of the callback. It is safe to pass the local instance // of the callback, because the underlying boost functions make copies // as needed. - HttpAcceptorCallback cb = boost::bind(&HttpConnection::acceptorCallback, - shared_from_this(), - boost::asio::placeholders::error); + HttpAcceptorCallback cb = std::bind(&HttpConnection::acceptorCallback, + shared_from_this(), + std::placeholders::_1); // error try { acceptor_.asyncAccept(socket_, cb); @@ -129,13 +129,13 @@ HttpConnection::doRead(TransactionPtr transaction) { } // Create instance of the callback. It is safe to pass the local instance - // of the callback, because the underlying boost functions make copies + // of the callback, because the underlying std functions make copies // as needed. - SocketCallback cb(boost::bind(&HttpConnection::socketReadCallback, - shared_from_this(), - transaction, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); + SocketCallback cb(std::bind(&HttpConnection::socketReadCallback, + shared_from_this(), + transaction, + std::placeholders::_1, // error + std::placeholders::_2)); //bytes_transferred socket_.asyncReceive(static_cast(transaction->getInputBufData()), transaction->getInputBufSize(), 0, &endpoint, cb); @@ -150,13 +150,13 @@ HttpConnection::doWrite(HttpConnection::TransactionPtr transaction) { try { if (transaction->outputDataAvail()) { // Create instance of the callback. It is safe to pass the local instance - // of the callback, because the underlying boost functions make copies + // of the callback, because the underlying std functions make copies // as needed. - SocketCallback cb(boost::bind(&HttpConnection::socketWriteCallback, - shared_from_this(), - transaction, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); + SocketCallback cb(std::bind(&HttpConnection::socketWriteCallback, + shared_from_this(), + transaction, + std::placeholders::_1, // error + std::placeholders::_2)); // bytes_transferred socket_.asyncSend(transaction->getOutputBufData(), transaction->getOutputBufSize(), cb); @@ -359,15 +359,15 @@ HttpConnection::setupRequestTimer(TransactionPtr transaction) { // because IntervalTimer already passes shared pointer to the // IntervalTimerImpl to make sure that the callback remains // valid. - request_timer_.setup(boost::bind(&HttpConnection::requestTimeoutCallback, - this, transaction), + request_timer_.setup(std::bind(&HttpConnection::requestTimeoutCallback, + this, transaction), request_timeout_, IntervalTimer::ONE_SHOT); } void HttpConnection::setupIdleTimer() { - request_timer_.setup(boost::bind(&HttpConnection::idleTimeoutCallback, - this), + request_timer_.setup(std::bind(&HttpConnection::idleTimeoutCallback, + this), idle_timeout_, IntervalTimer::ONE_SHOT); } diff --git a/src/lib/http/connection.h b/src/lib/http/connection.h index 3c3c3ffad8..a24f32303a 100644 --- a/src/lib/http/connection.h +++ b/src/lib/http/connection.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,11 +12,11 @@ #include #include #include -#include #include #include #include #include +#include #include namespace isc { @@ -45,7 +45,7 @@ private: /// @brief Type of the function implementing a callback invoked by the /// @c SocketCallback functor. - typedef boost::function + typedef std::function SocketCallbackFunction; /// @brief Functor associated with the socket object. diff --git a/src/lib/http/http_acceptor.h b/src/lib/http/http_acceptor.h index 4d52f7b181..9ef70123b4 100644 --- a/src/lib/http/http_acceptor.h +++ b/src/lib/http/http_acceptor.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,14 +8,14 @@ #define HTTP_ACCEPTOR_H #include -#include #include +#include namespace isc { namespace http { /// @brief Type of the callback for the TCP acceptor used in this library. -typedef boost::function +typedef std::function HttpAcceptorCallback; /// @brief Type of the TCP acceptor used in this library. diff --git a/src/lib/http/http_message_parser_base.cc b/src/lib/http/http_message_parser_base.cc index f3b12b0767..c44d28fda2 100644 --- a/src/lib/http/http_message_parser_base.cc +++ b/src/lib/http/http_message_parser_base.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,7 +7,7 @@ #include #include -#include +#include #include using namespace isc::util; @@ -126,15 +126,15 @@ HttpMessageParserBase::defineStates() { StateModel::defineStates(); defineState(HTTP_PARSE_OK_ST, "HTTP_PARSE_OK_ST", - boost::bind(&HttpMessageParserBase::parseEndedHandler, this)); + std::bind(&HttpMessageParserBase::parseEndedHandler, this)); defineState(HTTP_PARSE_FAILED_ST, "HTTP_PARSE_FAILED_ST", - boost::bind(&HttpMessageParserBase::parseEndedHandler, this)); + std::bind(&HttpMessageParserBase::parseEndedHandler, this)); } void HttpMessageParserBase::stateWithReadHandler(const std::string& handler_name, - boost::function + std::function after_read_logic) { std::string bytes; getNextFromBuffer(bytes); @@ -153,7 +153,7 @@ HttpMessageParserBase::stateWithReadHandler(const std::string& handler_name, void HttpMessageParserBase::stateWithMultiReadHandler(const std::string& handler_name, - boost::function + std::function after_read_logic) { std::string bytes; getNextFromBuffer(bytes, 0); diff --git a/src/lib/http/http_message_parser_base.h b/src/lib/http/http_message_parser_base.h index cbff213bd4..01f9831e2d 100644 --- a/src/lib/http/http_message_parser_base.h +++ b/src/lib/http/http_message_parser_base.h @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include namespace isc { @@ -195,7 +195,7 @@ protected: /// /// @throw HttpRequestParserError when invalid event occurred. void stateWithReadHandler(const std::string& handler_name, - boost::function + std::function after_read_logic); /// @brief Generic parser handler which reads multiple bytes of data and @@ -215,7 +215,7 @@ protected: /// /// @throw HttpRequestParserError when invalid event occurred. void stateWithMultiReadHandler(const std::string& handler_name, - boost::function + std::function after_read_logic); /// @brief Transition parser to failure state. diff --git a/src/lib/http/listener_impl.cc b/src/lib/http/listener_impl.cc index 058e8283c0..d6ab95f4bb 100644 --- a/src/lib/http/listener_impl.cc +++ b/src/lib/http/listener_impl.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2019-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -88,7 +88,8 @@ HttpListenerImpl::accept() { // depends on the use case. HttpResponseCreatorPtr response_creator = creator_factory_->create(); HttpAcceptorCallback acceptor_callback = - boost::bind(&HttpListenerImpl::acceptHandler, this, _1); + std::bind(&HttpListenerImpl::acceptHandler, this, + std::placeholders::_1); HttpConnectionPtr conn = createConnection(response_creator, acceptor_callback); // Add this new connection to the pool. diff --git a/src/lib/http/request_parser.cc b/src/lib/http/request_parser.cc index 3ebf824840..d774807017 100644 --- a/src/lib/http/request_parser.cc +++ b/src/lib/http/request_parser.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,7 +7,7 @@ #include #include -#include +#include #include using namespace isc::util; @@ -61,83 +61,83 @@ HttpRequestParser::defineStates() { // Define HTTP parser specific states. defineState(RECEIVE_START_ST, "RECEIVE_START_ST", - boost::bind(&HttpRequestParser::receiveStartHandler, this)); + std::bind(&HttpRequestParser::receiveStartHandler, this)); defineState(HTTP_METHOD_ST, "HTTP_METHOD_ST", - boost::bind(&HttpRequestParser::httpMethodHandler, this)); + std::bind(&HttpRequestParser::httpMethodHandler, this)); defineState(HTTP_URI_ST, "HTTP_URI_ST", - boost::bind(&HttpRequestParser::uriHandler, this)); + std::bind(&HttpRequestParser::uriHandler, this)); defineState(HTTP_VERSION_H_ST, "HTTP_VERSION_H_ST", - boost::bind(&HttpRequestParser::versionHTTPHandler, this, 'H', - HTTP_VERSION_T1_ST)); + std::bind(&HttpRequestParser::versionHTTPHandler, this, 'H', + HTTP_VERSION_T1_ST)); defineState(HTTP_VERSION_T1_ST, "HTTP_VERSION_T1_ST", - boost::bind(&HttpRequestParser::versionHTTPHandler, this, 'T', - HTTP_VERSION_T2_ST)); + std::bind(&HttpRequestParser::versionHTTPHandler, this, 'T', + HTTP_VERSION_T2_ST)); defineState(HTTP_VERSION_T2_ST, "HTTP_VERSION_T2_ST", - boost::bind(&HttpRequestParser::versionHTTPHandler, this, 'T', - HTTP_VERSION_P_ST)); + std::bind(&HttpRequestParser::versionHTTPHandler, this, 'T', + HTTP_VERSION_P_ST)); defineState(HTTP_VERSION_P_ST, "HTTP_VERSION_P_ST", - boost::bind(&HttpRequestParser::versionHTTPHandler, this, 'P', - HTTP_VERSION_SLASH_ST)); + std::bind(&HttpRequestParser::versionHTTPHandler, this, 'P', + HTTP_VERSION_SLASH_ST)); defineState(HTTP_VERSION_SLASH_ST, "HTTP_VERSION_SLASH_ST", - boost::bind(&HttpRequestParser::versionHTTPHandler, this, '/', - HTTP_VERSION_MAJOR_ST)); + std::bind(&HttpRequestParser::versionHTTPHandler, this, '/', + HTTP_VERSION_MAJOR_ST)); defineState(HTTP_VERSION_MAJOR_START_ST, "HTTP_VERSION_MAJOR_START_ST", - boost::bind(&HttpRequestParser::versionNumberStartHandler, this, - HTTP_VERSION_MAJOR_ST, - &context_->http_version_major_)); + std::bind(&HttpRequestParser::versionNumberStartHandler, this, + HTTP_VERSION_MAJOR_ST, + &context_->http_version_major_)); defineState(HTTP_VERSION_MAJOR_ST, "HTTP_VERSION_MAJOR_ST", - boost::bind(&HttpRequestParser::versionNumberHandler, this, - '.', HTTP_VERSION_MINOR_START_ST, - &context_->http_version_major_)); + std::bind(&HttpRequestParser::versionNumberHandler, this, + '.', HTTP_VERSION_MINOR_START_ST, + &context_->http_version_major_)); defineState(HTTP_VERSION_MINOR_START_ST, "HTTP_VERSION_MINOR_START_ST", - boost::bind(&HttpRequestParser::versionNumberStartHandler, this, - HTTP_VERSION_MINOR_ST, - &context_->http_version_minor_)); + std::bind(&HttpRequestParser::versionNumberStartHandler, this, + HTTP_VERSION_MINOR_ST, + &context_->http_version_minor_)); defineState(HTTP_VERSION_MINOR_ST, "HTTP_VERSION_MINOR_ST", - boost::bind(&HttpRequestParser::versionNumberHandler, this, - '\r', EXPECTING_NEW_LINE1_ST, - &context_->http_version_minor_)); + std::bind(&HttpRequestParser::versionNumberHandler, this, + '\r', EXPECTING_NEW_LINE1_ST, + &context_->http_version_minor_)); defineState(EXPECTING_NEW_LINE1_ST, "EXPECTING_NEW_LINE1_ST", - boost::bind(&HttpRequestParser::expectingNewLineHandler, this, - HEADER_LINE_START_ST)); + std::bind(&HttpRequestParser::expectingNewLineHandler, this, + HEADER_LINE_START_ST)); defineState(HEADER_LINE_START_ST, "HEADER_LINE_START_ST", - boost::bind(&HttpRequestParser::headerLineStartHandler, this)); + std::bind(&HttpRequestParser::headerLineStartHandler, this)); defineState(HEADER_LWS_ST, "HEADER_LWS_ST", - boost::bind(&HttpRequestParser::headerLwsHandler, this)); + std::bind(&HttpRequestParser::headerLwsHandler, this)); defineState(HEADER_NAME_ST, "HEADER_NAME_ST", - boost::bind(&HttpRequestParser::headerNameHandler, this)); + std::bind(&HttpRequestParser::headerNameHandler, this)); defineState(SPACE_BEFORE_HEADER_VALUE_ST, "SPACE_BEFORE_HEADER_VALUE_ST", - boost::bind(&HttpRequestParser::spaceBeforeHeaderValueHandler, this)); + std::bind(&HttpRequestParser::spaceBeforeHeaderValueHandler, this)); defineState(HEADER_VALUE_ST, "HEADER_VALUE_ST", - boost::bind(&HttpRequestParser::headerValueHandler, this)); + std::bind(&HttpRequestParser::headerValueHandler, this)); defineState(EXPECTING_NEW_LINE2_ST, "EXPECTING_NEW_LINE2", - boost::bind(&HttpRequestParser::expectingNewLineHandler, this, - HEADER_LINE_START_ST)); + std::bind(&HttpRequestParser::expectingNewLineHandler, this, + HEADER_LINE_START_ST)); defineState(EXPECTING_NEW_LINE3_ST, "EXPECTING_NEW_LINE3_ST", - boost::bind(&HttpRequestParser::expectingNewLineHandler, this, - HTTP_PARSE_OK_ST)); + std::bind(&HttpRequestParser::expectingNewLineHandler, this, + HTTP_PARSE_OK_ST)); defineState(HTTP_BODY_ST, "HTTP_BODY_ST", - boost::bind(&HttpRequestParser::bodyHandler, this)); + std::bind(&HttpRequestParser::bodyHandler, this)); } void diff --git a/src/lib/http/response_parser.cc b/src/lib/http/response_parser.cc index 78748baaa2..b2ab797caf 100644 --- a/src/lib/http/response_parser.cc +++ b/src/lib/http/response_parser.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,7 +7,7 @@ #include #include -#include +#include using namespace isc::util; @@ -62,95 +62,95 @@ HttpResponseParser::defineStates() { // Define HTTP parser specific states. defineState(RECEIVE_START_ST, "RECEIVE_START_ST", - boost::bind(&HttpResponseParser::receiveStartHandler, this)); + std::bind(&HttpResponseParser::receiveStartHandler, this)); defineState(HTTP_VERSION_T1_ST, "HTTP_VERSION_T1_ST", - boost::bind(&HttpResponseParser::versionHTTPHandler, this, 'T', - HTTP_VERSION_T2_ST)); + std::bind(&HttpResponseParser::versionHTTPHandler, this, 'T', + HTTP_VERSION_T2_ST)); defineState(HTTP_VERSION_T2_ST, "HTTP_VERSION_T2_ST", - boost::bind(&HttpResponseParser::versionHTTPHandler, this, 'T', - HTTP_VERSION_P_ST)); + std::bind(&HttpResponseParser::versionHTTPHandler, this, 'T', + HTTP_VERSION_P_ST)); defineState(HTTP_VERSION_P_ST, "HTTP_VERSION_P_ST", - boost::bind(&HttpResponseParser::versionHTTPHandler, this, 'P', - HTTP_VERSION_SLASH_ST)); + std::bind(&HttpResponseParser::versionHTTPHandler, this, 'P', + HTTP_VERSION_SLASH_ST)); defineState(HTTP_VERSION_SLASH_ST, "HTTP_VERSION_SLASH_ST", - boost::bind(&HttpResponseParser::versionHTTPHandler, this, '/', - HTTP_VERSION_MAJOR_ST)); + std::bind(&HttpResponseParser::versionHTTPHandler, this, '/', + HTTP_VERSION_MAJOR_ST)); defineState(HTTP_VERSION_MAJOR_START_ST, "HTTP_VERSION_MAJOR_START_ST", - boost::bind(&HttpResponseParser::numberStartHandler, this, - HTTP_VERSION_MAJOR_ST, - "HTTP version", - &context_->http_version_major_)); + std::bind(&HttpResponseParser::numberStartHandler, this, + HTTP_VERSION_MAJOR_ST, + "HTTP version", + &context_->http_version_major_)); defineState(HTTP_VERSION_MAJOR_ST, "HTTP_VERSION_MAJOR_ST", - boost::bind(&HttpResponseParser::numberHandler, this, - '.', HTTP_VERSION_MINOR_START_ST, - "HTTP version", - &context_->http_version_major_)); + std::bind(&HttpResponseParser::numberHandler, this, + '.', HTTP_VERSION_MINOR_START_ST, + "HTTP version", + &context_->http_version_major_)); defineState(HTTP_VERSION_MINOR_START_ST, "HTTP_VERSION_MINOR_START_ST", - boost::bind(&HttpResponseParser::numberStartHandler, this, - HTTP_VERSION_MINOR_ST, - "HTTP version", - &context_->http_version_minor_)); + std::bind(&HttpResponseParser::numberStartHandler, this, + HTTP_VERSION_MINOR_ST, + "HTTP version", + &context_->http_version_minor_)); defineState(HTTP_VERSION_MINOR_ST, "HTTP_VERSION_MINOR_ST", - boost::bind(&HttpResponseParser::numberHandler, this, - ' ', HTTP_STATUS_CODE_START_ST, - "HTTP version", - &context_->http_version_minor_)); + std::bind(&HttpResponseParser::numberHandler, this, + ' ', HTTP_STATUS_CODE_START_ST, + "HTTP version", + &context_->http_version_minor_)); defineState(HTTP_STATUS_CODE_START_ST, "HTTP_STATUS_CODE_START_ST", - boost::bind(&HttpResponseParser::numberStartHandler, this, - HTTP_STATUS_CODE_ST, - "HTTP status code", - &context_->status_code_)); + std::bind(&HttpResponseParser::numberStartHandler, this, + HTTP_STATUS_CODE_ST, + "HTTP status code", + &context_->status_code_)); defineState(HTTP_STATUS_CODE_ST, "HTTP_STATUS_CODE_ST", - boost::bind(&HttpResponseParser::numberHandler, this, - ' ', HTTP_PHRASE_START_ST, - "HTTP status code", - &context_->status_code_)); + std::bind(&HttpResponseParser::numberHandler, this, + ' ', HTTP_PHRASE_START_ST, + "HTTP status code", + &context_->status_code_)); defineState(HTTP_PHRASE_START_ST, "HTTP_PHRASE_START_ST", - boost::bind(&HttpResponseParser::phraseStartHandler, this)); + std::bind(&HttpResponseParser::phraseStartHandler, this)); defineState(HTTP_PHRASE_ST, "HTTP_PHRASE_ST", - boost::bind(&HttpResponseParser::phraseHandler, this)); + std::bind(&HttpResponseParser::phraseHandler, this)); defineState(EXPECTING_NEW_LINE1_ST, "EXPECTING_NEW_LINE1_ST", - boost::bind(&HttpResponseParser::expectingNewLineHandler, this, - HEADER_LINE_START_ST)); + std::bind(&HttpResponseParser::expectingNewLineHandler, this, + HEADER_LINE_START_ST)); defineState(HEADER_LINE_START_ST, "HEADER_LINE_START_ST", - boost::bind(&HttpResponseParser::headerLineStartHandler, this)); + std::bind(&HttpResponseParser::headerLineStartHandler, this)); defineState(HEADER_LWS_ST, "HEADER_LWS_ST", - boost::bind(&HttpResponseParser::headerLwsHandler, this)); + std::bind(&HttpResponseParser::headerLwsHandler, this)); defineState(HEADER_NAME_ST, "HEADER_NAME_ST", - boost::bind(&HttpResponseParser::headerNameHandler, this)); + std::bind(&HttpResponseParser::headerNameHandler, this)); defineState(SPACE_BEFORE_HEADER_VALUE_ST, "SPACE_BEFORE_HEADER_VALUE_ST", - boost::bind(&HttpResponseParser::spaceBeforeHeaderValueHandler, this)); + std::bind(&HttpResponseParser::spaceBeforeHeaderValueHandler, this)); defineState(HEADER_VALUE_ST, "HEADER_VALUE_ST", - boost::bind(&HttpResponseParser::headerValueHandler, this)); + std::bind(&HttpResponseParser::headerValueHandler, this)); defineState(EXPECTING_NEW_LINE2_ST, "EXPECTING_NEW_LINE2", - boost::bind(&HttpResponseParser::expectingNewLineHandler, this, - HEADER_LINE_START_ST)); + std::bind(&HttpResponseParser::expectingNewLineHandler, this, + HEADER_LINE_START_ST)); defineState(EXPECTING_NEW_LINE3_ST, "EXPECTING_NEW_LINE3_ST", - boost::bind(&HttpResponseParser::expectingNewLineHandler, this, - HTTP_PARSE_OK_ST)); + std::bind(&HttpResponseParser::expectingNewLineHandler, this, + HTTP_PARSE_OK_ST)); defineState(HTTP_BODY_ST, "HTTP_BODY_ST", - boost::bind(&HttpResponseParser::bodyHandler, this)); + std::bind(&HttpResponseParser::bodyHandler, this)); } void diff --git a/src/lib/http/tests/server_client_unittests.cc b/src/lib/http/tests/server_client_unittests.cc index 5ab1d5e9ec..12c7e4c6c8 100644 --- a/src/lib/http/tests/server_client_unittests.cc +++ b/src/lib/http/tests/server_client_unittests.cc @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -37,6 +36,7 @@ using namespace isc::data; using namespace isc::http; using namespace isc::http::test; using namespace isc::util; +namespace ph = std::placeholders; namespace { @@ -593,7 +593,7 @@ public: HttpListenerTest() : io_service_(), factory_(new TestHttpResponseCreatorFactory()), test_timer_(io_service_), run_io_service_timer_(io_service_), clients_() { - test_timer_.setup(boost::bind(&HttpListenerTest::timeoutHandler, this, true), + test_timer_.setup(std::bind(&HttpListenerTest::timeoutHandler, this, true), TEST_TIMEOUT, IntervalTimer::ONE_SHOT); } @@ -639,8 +639,8 @@ public: io_service_.get_io_service().reset(); if (timeout > 0) { - run_io_service_timer_.setup(boost::bind(&HttpListenerTest::timeoutHandler, - this, false), + run_io_service_timer_.setup(std::bind(&HttpListenerTest::timeoutHandler, + this, false), timeout, IntervalTimer::ONE_SHOT); } io_service_.run(); @@ -1686,8 +1686,8 @@ public: EXPECT_FALSE(ec); }, HttpClient::RequestTimeout(10000), - boost::bind(&ExternalMonitor::connectHandler, &monitor, _1, _2), - boost::bind(&ExternalMonitor::closeHandler, &monitor, _1) + std::bind(&ExternalMonitor::connectHandler, &monitor, ph::_1, ph::_2), + std::bind(&ExternalMonitor::closeHandler, &monitor, ph::_1) )); // Initiate another request to the destination. @@ -1703,8 +1703,8 @@ public: EXPECT_FALSE(ec); }, HttpClient::RequestTimeout(10000), - boost::bind(&ExternalMonitor::connectHandler, &monitor, _1, _2), - boost::bind(&ExternalMonitor::closeHandler, &monitor, _1) + std::bind(&ExternalMonitor::connectHandler, &monitor, ph::_1, ph::_2), + std::bind(&ExternalMonitor::closeHandler, &monitor, ph::_1) )); // Actually trigger the requests. The requests should be handlded by the @@ -1790,8 +1790,8 @@ public: EXPECT_FALSE(ec); }, HttpClient::RequestTimeout(10000), - boost::bind(&ExternalMonitor::connectHandler, &monitor, _1, _2), - boost::bind(&ExternalMonitor::closeHandler, &monitor, _1) + std::bind(&ExternalMonitor::connectHandler, &monitor, ph::_1, ph::_2), + std::bind(&ExternalMonitor::closeHandler, &monitor, ph::_1) )); // Actually trigger the requests. The requests should be handlded by the @@ -1848,8 +1848,8 @@ public: EXPECT_FALSE(ec); }, HttpClient::RequestTimeout(10000), - boost::bind(&ExternalMonitor::connectHandler, &monitor, _1, _2), - boost::bind(&ExternalMonitor::closeHandler, &monitor, _1) + std::bind(&ExternalMonitor::connectHandler, &monitor, ph::_1, ph::_2), + std::bind(&ExternalMonitor::closeHandler, &monitor, ph::_1) )); // Actually trigger the requests. The requests should be handlded by the diff --git a/src/lib/process/d_controller.cc b/src/lib/process/d_controller.cc index 2e0c28d88c..ae14572ec0 100644 --- a/src/lib/process/d_controller.cc +++ b/src/lib/process/d_controller.cc @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -739,9 +739,10 @@ DControllerBase::initSignalHandling() { // Create our signal set. io_signal_set_.reset(new IOSignalSet(io_service_, - boost::bind(&DControllerBase:: - processSignal, - this, _1))); + std::bind(&DControllerBase:: + processSignal, + this, + std::placeholders::_1))); // Register for the signals we wish to handle. io_signal_set_->add(SIGHUP); io_signal_set_->add(SIGINT); diff --git a/src/lib/process/daemon.cc b/src/lib/process/daemon.cc index 0b562a764c..0466706d2b 100644 --- a/src/lib/process/daemon.cc +++ b/src/lib/process/daemon.cc @@ -14,8 +14,7 @@ #include #include -#include - +#include #include #include #include @@ -62,8 +61,9 @@ void Daemon::shutdown() { } void Daemon::handleSignal() { + using namespace std::placeholders; if (signal_set_ && signal_handler_) { - signal_set_->handleNext(boost::bind(signal_handler_, _1)); + signal_set_->handleNext(std::bind(signal_handler_, _1)); } } diff --git a/src/lib/process/io_service_signal.cc b/src/lib/process/io_service_signal.cc index 76bbd54a02..6c14e9de56 100644 --- a/src/lib/process/io_service_signal.cc +++ b/src/lib/process/io_service_signal.cc @@ -10,10 +10,10 @@ #include #include -#include #include #include #include +#include using namespace isc::asiolink; @@ -82,8 +82,9 @@ IOSignalSetImpl::callback(const boost::system::error_code& ec, int signum) { void IOSignalSetImpl::install() { - signal_set_.async_wait(boost::bind(&IOSignalSetImpl::callback, - shared_from_this(), _1, _2)); + using namespace std::placeholders; + signal_set_.async_wait(std::bind(&IOSignalSetImpl::callback, + shared_from_this(), _1, _2)); } void diff --git a/src/lib/process/io_service_signal.h b/src/lib/process/io_service_signal.h index 22fe53b5d3..aa0691f054 100644 --- a/src/lib/process/io_service_signal.h +++ b/src/lib/process/io_service_signal.h @@ -15,7 +15,7 @@ namespace isc { namespace process { /// @brief Defines a handler function for an IOSignal. -typedef boost::function IOSignalHandler; +typedef std::function IOSignalHandler; class IOSignalSetImpl; diff --git a/src/lib/process/tests/io_service_signal_unittests.cc b/src/lib/process/tests/io_service_signal_unittests.cc index 4e04a2fc4d..f313998a59 100644 --- a/src/lib/process/tests/io_service_signal_unittests.cc +++ b/src/lib/process/tests/io_service_signal_unittests.cc @@ -9,9 +9,9 @@ #include #include -#include #include +#include #include namespace isc { @@ -52,8 +52,8 @@ public: io_signal_set_.reset(new IOSignalSet( io_service_, - boost::bind(&IOSignalTest::processSignal, - this, _1))); + std::bind(&IOSignalTest::processSignal, + this, std::placeholders::_1))); } /// @brief Destructor. @@ -91,8 +91,7 @@ public: void setTestTime(int test_time_ms) { // Fail safe shutdown test_time_ms_ = test_time_ms; - test_timer_.setup(boost::bind(&IOSignalTest::testTimerHandler, - this), + test_timer_.setup(std::bind(&IOSignalTest::testTimerHandler, this), test_time_ms_, asiolink::IntervalTimer::ONE_SHOT); } diff --git a/src/lib/process/testutils/d_test_stubs.cc b/src/lib/process/testutils/d_test_stubs.cc index a310824669..300035e24f 100644 --- a/src/lib/process/testutils/d_test_stubs.cc +++ b/src/lib/process/testutils/d_test_stubs.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -10,7 +10,7 @@ #include #include #include -#include +#include using namespace boost::asio; @@ -194,7 +194,7 @@ DControllerTest::scheduleTimedWrite(const std::string& config, int write_time_ms) { new_cfg_content_ = config; write_timer_.reset(new asiolink::IntervalTimer(*getIOService())); - write_timer_->setup(boost::bind(&DControllerTest::timedWriteCallback, this), + write_timer_->setup(std::bind(&DControllerTest::timedWriteCallback, this), write_time_ms, asiolink::IntervalTimer::ONE_SHOT); } diff --git a/src/lib/util/process_spawn.cc b/src/lib/util/process_spawn.cc index a762038bde..1dc871c9c9 100644 --- a/src/lib/util/process_spawn.cc +++ b/src/lib/util/process_spawn.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -152,8 +152,8 @@ ProcessSpawnImpl::ProcessSpawnImpl(const std::string& executable, executable_(executable), args_(new char*[args.size() + 2]) { // Set the handler which is invoked immediately when the signal // is received. - signals_->setOnReceiptHandler(boost::bind(&ProcessSpawnImpl::waitForProcess, - this, _1)); + signals_->setOnReceiptHandler(std::bind(&ProcessSpawnImpl::waitForProcess, + this, std::placeholders::_1)); // Conversion of the arguments to the C-style array we start by setting // all pointers within an array to NULL to indicate that they haven't // been allocated yet. @@ -243,7 +243,7 @@ ProcessSpawnImpl::isRunning(const pid_t pid) const { << "' hasn't been spawned and it status cannot be" " returned"); } - return (proc->second.running_); + return (proc->second.running_); } bool diff --git a/src/lib/util/signal_set.h b/src/lib/util/signal_set.h index c7b52153e3..ab63276202 100644 --- a/src/lib/util/signal_set.h +++ b/src/lib/util/signal_set.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2014-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,9 +8,9 @@ #define SIGNAL_SET_H #include -#include #include #include +#include #include #include #include @@ -44,14 +44,14 @@ class SignalSet; /// @brief Pointer to the @c isc::util::SignalSet. typedef boost::shared_ptr SignalSetPtr; /// @brief Pointer to the signal handling function. -typedef boost::function SignalHandler; +typedef std::function SignalHandler; /// @brief Pointer to a signal handling function which returns bool result. /// /// The handler is expected to return true if the signal it was given has /// been processed (i.e. should not be recorded for deferred processing) or /// false in which case it will be recorded. -typedef boost::function BoolSignalHandler; +typedef std::function BoolSignalHandler; /// @brief Represents a collection of signals handled in a customized way. /// diff --git a/src/lib/util/state_model.cc b/src/lib/util/state_model.cc index afc6ee9981..6c9a13d8a2 100644 --- a/src/lib/util/state_model.cc +++ b/src/lib/util/state_model.cc @@ -6,7 +6,6 @@ #include #include -#include #include namespace isc { @@ -245,9 +244,9 @@ StateModel::verifyEvents() { void StateModel::defineStates() { defineState(NEW_ST, "NEW_ST", - boost::bind(&StateModel::nopStateHandler, this)); + std::bind(&StateModel::nopStateHandler, this)); defineState(END_ST, "END_ST", - boost::bind(&StateModel::nopStateHandler, this)); + std::bind(&StateModel::nopStateHandler, this)); } void diff --git a/src/lib/util/state_model.h b/src/lib/util/state_model.h index 42f2d05e5c..da297da95d 100644 --- a/src/lib/util/state_model.h +++ b/src/lib/util/state_model.h @@ -11,8 +11,8 @@ #include #include -#include #include +#include #include #include #include @@ -34,7 +34,7 @@ typedef LabeledValue Event; typedef LabeledValuePtr EventPtr; /// @brief Defines a pointer to an instance method for handling a state. -typedef boost::function StateHandler; +typedef std::function StateHandler; /// @brief State machine pausing modes. /// @@ -73,7 +73,7 @@ public: /// /// @code /// State(SOME_INT_VAL, "SOME_INT_VAL", - /// boost::bind(&StateModelDerivation::someHandler, this)); + /// std::bind(&StateModelDerivation::someHandler, this)); /// @endcode /// /// @throw StateModelError if label is null or blank. @@ -472,7 +472,7 @@ protected: /// /// // Add the states defined by the derivation. /// defineState(SOME_ST, "SOME_ST", - /// boost::bind(&StateModelDerivation::someHandler, this)); + /// std::bind(&StateModelDerivation::someHandler, this)); /// : /// } /// @endcode diff --git a/src/lib/util/tests/signal_set_unittest.cc b/src/lib/util/tests/signal_set_unittest.cc index b11cf917ac..5e02e7e185 100644 --- a/src/lib/util/tests/signal_set_unittest.cc +++ b/src/lib/util/tests/signal_set_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -16,6 +15,7 @@ namespace { using namespace isc; using namespace isc::util; +using namespace std::placeholders; /// @brief Test fixture class for @c isc::util::SignalSet class. /// @@ -109,14 +109,14 @@ TEST_F(SignalSetTest, twoSignals) { // second one should be dropped. ASSERT_EQ(0, raise(SIGHUP)); // Execute the first handler (for SIGHUP). - signal_set_->handleNext(boost::bind(&SignalSetTest::testHandler, _1)); + signal_set_->handleNext(std::bind(&SignalSetTest::testHandler, _1)); // The handler should have been called once and the signal // handled should be SIGHUP. EXPECT_EQ(1, handler_calls_); EXPECT_EQ(SIGHUP, signum_); // Next signal to be handled should be SIGINT. EXPECT_EQ(SIGINT, signal_set_->getNext()); - signal_set_->handleNext(boost::bind(&SignalSetTest::testHandler, _1)); + signal_set_->handleNext(std::bind(&SignalSetTest::testHandler, _1)); EXPECT_EQ(2, handler_calls_); EXPECT_EQ(SIGINT, signum_); // There should be no more waiting handlers. @@ -143,14 +143,13 @@ TEST_F(SignalSetTest, twoSignalSets) { // The signal set owns SIGHUP so it should be the next to handle. EXPECT_EQ(SIGHUP, signal_set_->getNext()); // Handle next signal owned by the secondary signal set. - secondary_signal_set_->handleNext(boost::bind(&SignalSetTest::testHandler, - _1)); + secondary_signal_set_->handleNext(std::bind(&SignalSetTest::testHandler, _1)); EXPECT_EQ(1, handler_calls_); EXPECT_EQ(SIGINT, signum_); // No more signals to be handled for this signal set. EXPECT_EQ(-1, secondary_signal_set_->getNext()); // Handle next signal owned by the signal set. - signal_set_->handleNext(boost::bind(&SignalSetTest::testHandler, _1)); + signal_set_->handleNext(std::bind(&SignalSetTest::testHandler, _1)); EXPECT_EQ(2, handler_calls_); EXPECT_EQ(SIGHUP, signum_); // No more signals to be handled by this signal set. @@ -200,8 +199,8 @@ TEST_F(SignalSetTest, duplicates) { /// Check that on-receipt processing works. TEST_F(SignalSetTest, onReceiptTests) { // Install an on-receipt handler. - SignalSet::setOnReceiptHandler(boost::bind(&SignalSetTest::onReceiptHandler, - this, _1)); + SignalSet::setOnReceiptHandler(std::bind(&SignalSetTest::onReceiptHandler, + this, _1)); // Create a SignalSet for SIGHUP and SIGUSR1. ASSERT_NO_THROW(signal_set_.reset(new SignalSet(SIGHUP, SIGUSR1))); @@ -220,7 +219,7 @@ TEST_F(SignalSetTest, onReceiptTests) { EXPECT_EQ(SIGUSR1, signal_set_->getNext()); // Verify we can process SIGUSR1 with the deferred handler. - signal_set_->handleNext(boost::bind(&SignalSetTest::testHandler, _1)); + signal_set_->handleNext(std::bind(&SignalSetTest::testHandler, _1)); EXPECT_EQ(1, handler_calls_); EXPECT_EQ(SIGUSR1, signum_); @@ -235,7 +234,7 @@ TEST_F(SignalSetTest, onReceiptTests) { EXPECT_EQ(SIGHUP, signal_set_->getNext()); // Verify we can process it with deferred handler. - signal_set_->handleNext(boost::bind(&SignalSetTest::testHandler, _1)); + signal_set_->handleNext(std::bind(&SignalSetTest::testHandler, _1)); EXPECT_EQ(2, handler_calls_); EXPECT_EQ(SIGHUP, signum_); } diff --git a/src/lib/util/tests/state_model_unittest.cc b/src/lib/util/tests/state_model_unittest.cc index a69030c6c0..eaaba738f4 100644 --- a/src/lib/util/tests/state_model_unittest.cc +++ b/src/lib/util/tests/state_model_unittest.cc @@ -8,8 +8,6 @@ #include -#include -#include #include using namespace std; @@ -208,23 +206,23 @@ public: // Define our states. defineState(DUMMY_ST, "DUMMY_ST", - boost::bind(&StateModelTest::dummyHandler, this)); + std::bind(&StateModelTest::dummyHandler, this)); defineState(READY_ST, "READY_ST", - boost::bind(&StateModelTest::readyHandler, this)); + std::bind(&StateModelTest::readyHandler, this)); defineState(DO_WORK_ST, "DO_WORK_ST", - boost::bind(&StateModelTest::doWorkHandler, this)); + std::bind(&StateModelTest::doWorkHandler, this)); defineState(DONE_ST, "DONE_ST", - boost::bind(&StateModelTest::doneWorkHandler, this)); + std::bind(&StateModelTest::doneWorkHandler, this)); defineState(PAUSE_ALWAYS_ST, "PAUSE_ALWAYS_ST", - boost::bind(&StateModelTest::pauseHandler, this), + std::bind(&StateModelTest::pauseHandler, this), STATE_PAUSE_ALWAYS); defineState(PAUSE_ONCE_ST, "PAUSE_ONCE_ST", - boost::bind(&StateModelTest::pauseHandler, this), + std::bind(&StateModelTest::pauseHandler, this), STATE_PAUSE_ONCE); } @@ -393,8 +391,8 @@ TEST_F(StateModelTest, stateDefinition) { // Verify that we can add a state to the dictionary. ASSERT_NO_THROW(defineState(READY_ST, "READY_ST", - boost::bind(&StateModelTest::dummyHandler, - this))); + std::bind(&StateModelTest::dummyHandler, + this))); // Verify that we can find the state by its value. StatePtr state; @@ -417,7 +415,7 @@ TEST_F(StateModelTest, stateDefinition) { // Verify that we cannot add a duplicate. EXPECT_THROW(defineState(READY_ST, "READY_ST", - boost::bind(&StateModelTest::readyHandler, this)), + std::bind(&StateModelTest::readyHandler, this)), StateModelError); // Verify that we can still find the state. @@ -604,8 +602,8 @@ TEST_F(StateModelTest, statusMethods) { // Verify that events and states can be added before the model is started. EXPECT_NO_THROW(defineEvent(9998, "9998")); EXPECT_NO_THROW(defineState(9998, "9998", - boost::bind(&StateModelTest::readyHandler, - this))); + std::bind(&StateModelTest::readyHandler, + this))); // "START" the model. // Fake out starting the model by calling transition to move from NEW_ST @@ -617,7 +615,7 @@ TEST_F(StateModelTest, statusMethods) { // Verify that events and states cannot be added after the model is started. EXPECT_THROW(defineEvent(9999, "9999"), StateModelError); EXPECT_THROW(defineState(9999, "9999", - boost::bind(&StateModelTest::readyHandler, this)), + std::bind(&StateModelTest::readyHandler, this)), StateModelError); // The state and event combos set above, should show the model as diff --git a/src/lib/util/tests/watched_thread_unittest.cc b/src/lib/util/tests/watched_thread_unittest.cc index caf61ccabc..9ac67f2196 100644 --- a/src/lib/util/tests/watched_thread_unittest.cc +++ b/src/lib/util/tests/watched_thread_unittest.cc @@ -8,11 +8,11 @@ #include -#include #include -#include #include +#include +#include using namespace std; using namespace isc; @@ -100,7 +100,7 @@ TEST_F(WatchedThreadTest, watchedThreadClassBasics) { /// our other tests as to why threads have finished are sound. wthread_.reset(new WatchedThread()); ASSERT_FALSE(wthread_->isRunning()); - wthread_->start(boost::bind(&WatchedThreadTest::worker, this, WatchedThread::TERMINATE)); + wthread_->start(std::bind(&WatchedThreadTest::worker, this, WatchedThread::TERMINATE)); ASSERT_TRUE(wthread_->isRunning()); // Wait more long enough (we hope) for the thread to expire. @@ -122,7 +122,7 @@ TEST_F(WatchedThreadTest, watchedThreadClassBasics) { /// Now we'll test stopping a thread. /// Start the WatchedThread, let it run a little and then tell it to stop. - wthread_->start(boost::bind(&WatchedThreadTest::worker, this, WatchedThread::TERMINATE)); + wthread_->start(std::bind(&WatchedThreadTest::worker, this, WatchedThread::TERMINATE)); ASSERT_TRUE(wthread_->isRunning()); // No watches should be ready. @@ -149,7 +149,7 @@ TEST_F(WatchedThreadTest, watchedThreadClassBasics) { // Next we'll test error notification. // Start the WatchedThread with a thread that sets an error on the second pass. - wthread_->start(boost::bind(&WatchedThreadTest::worker, this, WatchedThread::ERROR)); + wthread_->start(std::bind(&WatchedThreadTest::worker, this, WatchedThread::ERROR)); ASSERT_TRUE(wthread_->isRunning()); // No watches should be ready. @@ -180,7 +180,7 @@ TEST_F(WatchedThreadTest, watchedThreadClassBasics) { // Finally, we'll test data ready notification. // We'll start the WatchedThread with a thread that indicates data ready on its second pass. - wthread_->start(boost::bind(&WatchedThreadTest::worker, this, WatchedThread::READY)); + wthread_->start(std::bind(&WatchedThreadTest::worker, this, WatchedThread::READY)); ASSERT_TRUE(wthread_->isRunning()); // No watches should be ready. diff --git a/src/lib/util/watched_thread.cc b/src/lib/util/watched_thread.cc index 6cd86ab8b9..c01594b64e 100644 --- a/src/lib/util/watched_thread.cc +++ b/src/lib/util/watched_thread.cc @@ -11,7 +11,7 @@ namespace isc { namespace util { void -WatchedThread::start(const boost::function& thread_main) { +WatchedThread::start(const std::function& thread_main) { clearReady(ERROR); clearReady(READY); clearReady(TERMINATE); diff --git a/src/lib/util/watched_thread.h b/src/lib/util/watched_thread.h index d0f9203adb..47b72642f2 100644 --- a/src/lib/util/watched_thread.h +++ b/src/lib/util/watched_thread.h @@ -10,8 +10,8 @@ #include #include -#include +#include #include #include @@ -80,7 +80,7 @@ public: /// Creates the thread, passing into it the given function to run. /// /// @param thread_main function the thread should run - void start(const boost::function& thread_main); + void start(const std::function& thread_main); /// @brief Returns true if the thread is running bool isRunning() {