diff options
author | Francis Dupont <fdupont@isc.org> | 2020-07-31 00:04:26 +0200 |
---|---|---|
committer | Tomek Mrugalski <tomek@isc.org> | 2020-08-13 15:54:14 +0200 |
commit | 2035f64c1c0d0908c71b47a0c321ed66784e391c (patch) | |
tree | b9f69a38a572cb7afe2763143fc5c877b218ebad /src/lib | |
parent | [#285] Corrected changelog numbering (diff) | |
download | kea-2035f64c1c0d0908c71b47a0c321ed66784e391c.tar.xz kea-2035f64c1c0d0908c71b47a0c321ed66784e391c.zip |
[#1308] Got rid of boost function/bind
Diffstat (limited to 'src/lib')
84 files changed, 543 insertions, 525 deletions
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 <util/buffer.h> #include <util/random/qid_gen.h> -#include <boost/bind.hpp> #include <boost/scoped_ptr.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp> +#include <functional> #include <unistd.h> // for some IPC/network system calls #include <netinet/in.h> #include <stdint.h> @@ -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 <util/io_utilities.h> #include <gtest/gtest.h> -#include <boost/bind.hpp> #include <boost/date_time/posix_time/posix_time_types.hpp> #include <algorithm> #include <cstdlib> +#include <functional> #include <string> #include <iostream> #include <iomanip> #include <iterator> #include <vector> +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 <asiolink/interval_timer.h> #include <asiolink/io_service.h> -#include <boost/bind.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/noncopyable.hpp> #include <boost/shared_ptr.hpp> @@ -17,6 +16,7 @@ #include <exceptions/exceptions.h> #include <atomic> +#include <functional> #include <mutex> 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 <boost/function.hpp> #include <boost/shared_ptr.hpp> +#include <functional> #include <asiolink/io_service.h> @@ -52,7 +52,7 @@ class IntervalTimerImpl; class IntervalTimer { public: /// \name The type of timer callback function - typedef boost::function<void()> Callback; + typedef std::function<void()> 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<void()>& callback) : + CallbackWrapper(const std::function<void()>& callback) : callback_(callback) {} void operator()() { callback_(); } private: - boost::function<void()> callback_; + std::function<void()> 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<void ()>& callback) { + void post(const std::function<void ()>& callback) { const CallbackWrapper wrapper(callback); io_service_.post(wrapper); } @@ -138,7 +138,7 @@ IOService::get_io_service() { } void -IOService::post(const boost::function<void ()>& callback) { +IOService::post(const std::function<void ()>& 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 <boost/function.hpp> +#include <boost/version.hpp> +#include <boost/shared_ptr.hpp> +#include <functional> 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<void ()>& callback); + void post(const std::function<void ()>& 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 <asiolink/io_service.h> #include <gtest/gtest.h> -#include <boost/bind.hpp> +#include <functional> #include <vector> using namespace isc::asiolink; @@ -26,9 +26,9 @@ TEST(IOService, post) { std::vector<int> 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 <asiolink/io_service.h> #include <asiolink/tcp_acceptor.h> #include <asiolink/tcp_endpoint.h> -#include <boost/bind.hpp> -#include <boost/function.hpp> #include <boost/noncopyable.hpp> #include <boost/shared_ptr.hpp> #include <gtest/gtest.h> +#include <functional> #include <list> #include <netinet/in.h> #include <string> @@ -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<TCPClient> TCPClientPtr; /// @brief A signature of the function implementing callback for the /// TCPAcceptor. -typedef boost::function<void(const boost::system::error_code&)> TCPAcceptorCallback; +typedef std::function<void(const boost::system::error_code&)> TCPAcceptorCallback; /// @brief TCPAcceptor using TCPAcceptorCallback. typedef TCPAcceptor<TCPAcceptorCallback> 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 <asiolink/asio_wrapper.h> #include <asiolink/testutils/test_server_unix_socket.h> -#include <boost/bind.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/shared_ptr.hpp> #include <functional> @@ -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 <asiolink/asio_wrapper.h> #include <asiolink/unix_domain_socket.h> -#include <boost/bind.hpp> #include <boost/enable_shared_from_this.hpp> +#include <functional> #include <iostream> 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 <cc/data.h> #include <cc/json_feed.h> -#include <boost/bind.hpp> +#include <functional> 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 <config/config_log.h> #include <hooks/callout_handle.h> #include <hooks/hooks_manager.h> -#include <boost/bind.hpp> +#include <functional> 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 <cc/data.h> #include <exceptions/exceptions.h> -#include <boost/function.hpp> +#include <functional> #include <map> #include <string> @@ -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<isc::data::ConstElementPtr (const std::string& name, + typedef std::function<isc::data::ConstElementPtr (const std::string& name, const isc::data::ConstElementPtr& params)> 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<isc::data::ConstElementPtr (const std::string& name, + typedef std::function<isc::data::ConstElementPtr (const std::string& name, const isc::data::ConstElementPtr& params, const isc::data::ConstElementPtr& original)> 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 <asiolink/unix_domain_socket.h> #include <cc/json_feed.h> #include <config/client_connection.h> -#include <boost/bind.hpp> #include <boost/enable_shared_from_this.hpp> #include <array> +#include <functional> 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 <config/config_log.h> #include <config/timeouts.h> #include <util/watch_socket.h> -#include <boost/bind.hpp> #include <boost/enable_shared_from_this.hpp> #include <array> +#include <functional> #include <unistd.h> #include <sys/file.h> @@ -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 <cc/data.h> #include <boost/noncopyable.hpp> -#include <boost/function.hpp> #include <boost/shared_ptr.hpp> #include <exceptions/exceptions.h> +#include <functional> #include <map> #include <string> @@ -220,7 +220,7 @@ public: bool configuredReadOnly() const; /// @brief Defines a callback prototype for propogating events upward - typedef boost::function<bool (ReconnectCtlPtr db_retry)> DbLostCallback; + typedef std::function<bool (ReconnectCtlPtr db_retry)> 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 <exceptions/exceptions.h> #include <gtest/gtest.h> -#include <boost/bind.hpp> +#include <functional> 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 <util/multi_threading_mgr.h> #include <boost/scoped_ptr.hpp> -#include <boost/bind.hpp> #include <cstring> #include <errno.h> #include <fstream> +#include <functional> #include <limits> #include <sstream> @@ -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 <util/watch_socket.h> #include <util/watched_thread.h> -#include <boost/function.hpp> #include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/mem_fun.hpp> #include <boost/multi_index/sequenced_index.hpp> @@ -29,6 +28,7 @@ #include <boost/scoped_array.hpp> #include <boost/shared_ptr.hpp> +#include <functional> #include <list> #include <vector> #include <mutex> @@ -621,7 +621,7 @@ typedef boost::shared_ptr<IfaceMgr> IfaceMgrPtr; /// /// @param errmsg An error message. typedef -boost::function<void(const std::string& errmsg)> IfaceMgrErrorMsgCallback; +std::function<void(const std::string& errmsg)> 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<void (int fd)> SocketCallback; + typedef std::function<void (int fd)> 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 <dhcp/tests/packet_queue_testutils.h> #include <testutils/gtest_utils.h> -#include <boost/bind.hpp> #include <boost/foreach.hpp> #include <boost/scoped_ptr.hpp> #include <gtest/gtest.h> #include <fcntl.h> #include <fstream> +#include <functional> #include <iostream> #include <sstream> @@ -31,6 +31,7 @@ #include <unistd.h> 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 <dhcp_ddns/dhcp_ddns_log.h> #include <dhcp_ddns/ncr_udp.h> -#include <boost/bind.hpp> +#include <functional> 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<void(const bool, const UDPCallback*)> +typedef std::function<void(const bool, const UDPCallback*)> 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 <test_utils.h> #include <boost/asio/ip/udp.hpp> -#include <boost/function.hpp> -#include <boost/bind.hpp> +#include <functional> #include <algorithm> #include <sys/select.h> @@ -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 <utility> #include <vector> - 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<Lease6Ptr>(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<Lease4Ptr>(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<typename LeasePtrType> void AllocEngine::reclaimLeaseInDatabase(const LeasePtrType& lease, const bool remove_lease, - const boost::function<void (const LeasePtrType&)>& + const std::function<void (const LeasePtrType&)>& 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 <util/multi_threading_mgr.h> #include <util/readwrite_mutex.h> -#include <boost/function.hpp> #include <boost/shared_ptr.hpp> #include <boost/noncopyable.hpp> +#include <functional> #include <list> #include <map> #include <mutex> @@ -1268,7 +1268,7 @@ private: template<typename LeasePtrType> void reclaimLeaseInDatabase(const LeasePtrType& lease, const bool remove_lease, - const boost::function<void (const LeasePtrType&)>& + const std::function<void (const LeasePtrType&)>& 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 <asiolink/interval_timer.h> #include <cc/cfg_to_element.h> #include <dhcpsrv/timer_mgr.h> -#include <boost/bind.hpp> #include <boost/shared_ptr.hpp> +#include <functional> #include <stdint.h> #include <string> @@ -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 <dhcpsrv/dhcpsrv_log.h> #include <dhcpsrv/cfg_iface.h> #include <util/strutil.h> -#include <boost/bind.hpp> #include <algorithm> +#include <functional> 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 <dhcpsrv/d2_client_mgr.h> #include <dhcpsrv/dhcpsrv_log.h> -#include <boost/bind.hpp> - +#include <functional> #include <string> 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<void(const dhcp_ddns::NameChangeSender::Result result, - dhcp_ddns::NameChangeRequestPtr& ncr)> D2ClientErrorHandler; +std::function<void(const dhcp_ddns::NameChangeSender::Result result, + dhcp_ddns::NameChangeRequestPtr& ncr)> 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 <dhcpsrv/base_host_data_source.h> #include <exceptions/exceptions.h> #include <boost/scoped_ptr.hpp> -#include <boost/function.hpp> +#include <functional> #include <string> #include <vector> #include <map> @@ -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<HostDataSourcePtr (const db::DatabaseConnection::ParameterMap&)> Factory; + typedef std::function<HostDataSourcePtr (const db::DatabaseConnection::ParameterMap&)> 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 <exceptions/exceptions.h> #include <dhcpsrv/network_state.h> #include <dhcpsrv/timer_mgr.h> -#include <boost/bind.hpp> #include <boost/enable_shared_from_this.hpp> +#include <functional> #include <string> 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 <hooks/hooks_manager.h> #include <stats/stats_mgr.h> #include <gtest/gtest.h> -#include <boost/bind.hpp> -#include <boost/function.hpp> #include <boost/static_assert.hpp> +#include <functional> #include <iomanip> #include <sstream> #include <time.h> @@ -23,6 +22,7 @@ #include <vector> 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<bool (const LeasePtrType)> LeaseAlgorithmFun; + typedef std::function<bool (const LeasePtrType)> LeaseAlgorithmFun; /// @brief type definition for the lease index algorithm. - typedef boost::function<bool (const size_t)> IndexAlgorithmFun; + typedef std::function<bool (const size_t)> 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 <dhcpsrv/timer_mgr.h> #include <exceptions/exceptions.h> #include <testutils/test_to_element.h> -#include <boost/function.hpp> #include <boost/shared_ptr.hpp> #include <gtest/gtest.h> +#include <functional> #include <stdint.h> using namespace isc; @@ -23,13 +23,13 @@ using namespace isc::dhcp; namespace { /// @brief Type definition of the @c CfgExpiration modified function. -typedef boost::function<void(CfgExpiration*, const int64_t)> ModifierFun; +typedef std::function<void(CfgExpiration*, const int64_t)> ModifierFun; /// @brief Type definition of the @c CfgExpiration accessor function /// returning uint16_t value. -typedef boost::function<uint16_t(CfgExpiration*)> AccessorFunUint16; +typedef std::function<uint16_t(CfgExpiration*)> AccessorFunUint16; /// @brief Type definition of the @c CfgExpiration accessor function /// returning uint32_t value. -typedef boost::function<uint32_t(CfgExpiration*)> AccessorFunUint32; +typedef std::function<uint32_t(CfgExpiration*)> AccessorFunUint32; /// @brief Tests the accessor and modifier function for a particular /// configuration parameter held in @c CfgExpiration. @@ -50,7 +50,7 @@ typedef boost::function<uint32_t(CfgExpiration*)> AccessorFunUint32; template<typename ReturnType> void testAccessModify(const int64_t limit, const ModifierFun& modifier, - const boost::function<ReturnType(CfgExpiration*)>& accessor) { + const std::function<ReturnType(CfgExpiration*)>& 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 <dhcpsrv/d2_client_mgr.h> #include <exceptions/exceptions.h> -#include <boost/function.hpp> -#include <boost/bind.hpp> #include <gtest/gtest.h> +#include <functional> #include <sys/select.h> 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 <dhcp/option_int.h> #include <dhcpsrv/dhcp4o6_ipc.h> #include <dhcpsrv/testutils/dhcp4o6_test_ipc.h> -#include <boost/bind.hpp> -#include <boost/function.hpp> #include <gtest/gtest.h> +#include <functional> #include <sstream> #include <string> @@ -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<Pkt6Ptr(uint16_t, uint16_t)> CreateMsgFun; +typedef std::function<Pkt6Ptr(uint16_t, uint16_t)> 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 <sstream> 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 <dhcpsrv/d2_client_mgr.h> #include <dhcpsrv/lease.h> -#include <ctime> -#include <boost/bind.hpp> #include <gtest/gtest.h> - +#include <ctime> +#include <functional> #include <stdint.h> #include <string> @@ -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 <asiolink/io_service.h> #include <dhcpsrv/network_state.h> #include <dhcpsrv/timer_mgr.h> -#include <boost/bind.hpp> #include <gtest/gtest.h> +#include <functional> 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 <dhcpsrv/timer_mgr.h> #include <exceptions/exceptions.h> -#include <boost/bind.hpp> #include <gtest/gtest.h> +#include <functional> #include <sstream> #include <unistd.h> @@ -73,10 +73,10 @@ public: /// /// This is just a wrapped to make it a bit more convenient /// in the test. - boost::function<void ()> makeCallback(const std::string& timer_name); + std::function<void ()> makeCallback(const std::string& timer_name); /// @brief Create a callback which generates exception. - boost::function<void ()> makeCallbackWithException(); + std::function<void ()> makeCallbackWithException(); /// @brief Callback for timeout. /// @@ -154,14 +154,14 @@ TimerMgrTest::timerCallbackWithException() { isc_throw(Exception, "timerCallbackWithException"); } -boost::function<void ()> +std::function<void ()> 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<void ()> +std::function<void ()> 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 <config.h> #include <dhcp/iface_mgr.h> #include <dhcpsrv/testutils/dhcp4o6_test_ipc.h> -#include <boost/bind.hpp> +#include <functional> 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 <dhcpsrv/timer_mgr.h> #include <exceptions/exceptions.h> -#include <boost/bind.hpp> - +#include <functional> #include <utility> 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<MasterLoaderImpl> 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 <exceptions/exceptions.h> -#include <string> -#include <boost/function.hpp> #include <boost/shared_ptr.hpp> +#include <functional> +#include <string> namespace isc { namespace dns { @@ -35,9 +35,9 @@ typedef boost::shared_ptr<Rdata> 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<void(const Name& name, const RRClass& rrclass, - const RRType& rrtype, const RRTTL& rrttl, - const rdata::RdataPtr& rdata)> +typedef std::function<void(const Name& name, const RRClass& rrclass, + const RRType& rrtype, const RRTTL& rrttl, + const rdata::RdataPtr& rdata)> 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<void(const std::string& source_name, - size_t source_line, - const std::string& reason)> IssueCallback; + typedef std::function<void(const std::string& source_name, + size_t source_line, + const std::string& reason)> 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 <config.h> -#include <istream> -#include <fstream> -#include <sstream> -#include <string> -#include <cctype> -#include <cerrno> - -#include <boost/bind.hpp> -#include <boost/scoped_ptr.hpp> - -#include <exceptions/exceptions.h> - #include <dns/masterload.h> #include <dns/master_loader.h> #include <dns/name.h> @@ -28,9 +16,19 @@ #include <dns/rrttl.h> #include <dns/rrtype.h> #include <dns/rrcollator.h> +#include <exceptions/exceptions.h> + +#include <boost/scoped_ptr.hpp> + +#include <functional> +#include <istream> +#include <fstream> +#include <sstream> +#include <string> +#include <cctype> +#include <cerrno> 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 <iosfwd> - -#include <boost/function.hpp> - +#include <dns/rrset.h> #include <exceptions/exceptions.h> -#include <dns/rrset.h> +#include <functional> +#include <iosfwd> 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<void(RRsetPtr)> MasterLoadCallback; +typedef std::function<void(RRsetPtr)> MasterLoadCallback; /// /// \name Master zone file loader functions. @@ -48,7 +46,7 @@ typedef boost::function<void(RRsetPtr)> 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<void(RRsetPtr)> 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<void(RRsetPtr)> 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 <dns/rdata.h> #include <dns/rrset.h> -#include <boost/bind.hpp> - #include <algorithm> +#include <functional> 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 <dns/rrset.h> #include <boost/noncopyable.hpp> -#include <boost/function.hpp> +#include <functional> namespace isc { namespace dns { @@ -51,7 +51,7 @@ public: /// the \c RRCollator. /// /// \param rrset The collated RRset. - typedef boost::function<void(const RRsetPtr& rrset)> AddRRsetCallback; + typedef std::function<void(const RRsetPtr& rrset)> 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 <exceptions/exceptions.h> -#include <boost/bind.hpp> +#include <functional> 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 <exceptions/exceptions.h> #include <gtest/gtest.h> -#include <boost/bind.hpp> +#include <functional> 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 <gtest/gtest.h> -#include <boost/bind.hpp> #include <boost/lexical_cast.hpp> #include <boost/scoped_ptr.hpp> +#include <functional> #include <string> #include <vector> #include <list> #include <sstream> 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 <string> #include <vector> -#include <boost/bind.hpp> - #include <gtest/gtest.h> #include <dns/masterload.h> @@ -24,6 +22,7 @@ #include <dns/rrset.h> 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 <config.h> +#include <functional> #include <vector> #include <string> #include <sstream> @@ -24,10 +25,10 @@ #include <util/unittests/wiredata.h> -#include <boost/bind.hpp> #include <boost/lexical_cast.hpp> 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 <gtest/gtest.h> -#include <boost/bind.hpp> - +#include <functional> #include <sstream> #include <vector> 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 <gtest/gtest.h> -#include <boost/bind.hpp> #include <boost/scoped_ptr.hpp> #include <algorithm> +#include <functional> #include <string> #include <sstream> #include <vector> @@ -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 <dns/rrset.h> #include <dns/rrset_collection_base.h> -#include <boost/bind.hpp> #include <boost/lexical_cast.hpp> +#include <functional> #include <string> 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 <dns/dns_fwd.h> -#include <boost/function.hpp> - +#include <functional> #include <string> 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<void(const std::string& reason)> IssueCallback; + typedef std::function<void(const std::string& reason)> 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 <util/multi_threading_mgr.h> #include <util/unlock_guard.h> -#include <boost/bind.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/weak_ptr.hpp> #include <atomic> #include <array> +#include <functional> #include <iostream> #include <map> #include <mutex> @@ -41,7 +41,7 @@ namespace { constexpr size_t MAX_LOGGED_MESSAGE_SIZE = 1024; /// @brief TCP socket callback function type. -typedef boost::function<void(boost::system::error_code ec, size_t length)> +typedef std::function<void(boost::system::error_code ec, size_t length)> 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<unsigned short>(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<void*>(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 <http/connection_pool.h> #include <http/http_log.h> #include <http/http_messages.h> -#include <boost/bind.hpp> #include <boost/make_shared.hpp> +#include <functional> 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<void*>(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 <http/http_acceptor.h> #include <http/request_parser.h> #include <http/response_creator_factory.h> -#include <boost/function.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/system/error_code.hpp> #include <boost/shared_ptr.hpp> #include <array> +#include <functional> #include <string> namespace isc { @@ -45,7 +45,7 @@ private: /// @brief Type of the function implementing a callback invoked by the /// @c SocketCallback functor. - typedef boost::function<void(boost::system::error_code ec, size_t length)> + typedef std::function<void(boost::system::error_code ec, size_t length)> 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 <asiolink/tcp_acceptor.h> -#include <boost/function.hpp> #include <boost/system/system_error.hpp> +#include <functional> namespace isc { namespace http { /// @brief Type of the callback for the TCP acceptor used in this library. -typedef boost::function<void(const boost::system::error_code&)> +typedef std::function<void(const boost::system::error_code&)> 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 <config.h> #include <http/http_message_parser_base.h> -#include <boost/bind.hpp> +#include <functional> #include <sstream> 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<void(const char c)> + std::function<void(const char c)> 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<void(const std::string&)> + std::function<void(const std::string&)> 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 <exceptions/exceptions.h> #include <http/http_message.h> #include <util/state_model.h> -#include <boost/function.hpp> +#include <functional> #include <string> namespace isc { @@ -195,7 +195,7 @@ protected: /// /// @throw HttpRequestParserError when invalid event occurred. void stateWithReadHandler(const std::string& handler_name, - boost::function<void(const char c)> + std::function<void(const char c)> 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<void(const std::string&)> + std::function<void(const std::string&)> 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 <config.h> #include <http/request_parser.h> -#include <boost/bind.hpp> +#include <functional> #include <iostream> 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 <config.h> #include <http/response_parser.h> -#include <boost/bind.hpp> +#include <functional> 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 <boost/asio/buffer.hpp> #include <boost/asio/ip/tcp.hpp> -#include <boost/bind.hpp> #include <boost/pointer_cast.hpp> #include <gtest/gtest.h> @@ -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 <process/d_controller.h> #include <process/config_base.h> #include <kea_version.h> -#include <boost/bind.hpp> +#include <functional> #include <sstream> #include <unistd.h> @@ -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 <process/config_base.h> #include <util/filename.h> -#include <boost/bind.hpp> - +#include <functional> #include <sstream> #include <fstream> #include <errno.h> @@ -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 <process/io_service_signal.h> #include <exceptions/exceptions.h> -#include <boost/bind.hpp> #include <boost/enable_shared_from_this.hpp> #include <boost/noncopyable.hpp> #include <boost/asio/signal_set.hpp> +#include <functional> 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<void(int signum)> IOSignalHandler; +typedef std::function<void(int signum)> 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 <process/io_service_signal.h> #include <process/testutils/d_test_stubs.h> -#include <boost/bind.hpp> #include <gtest/gtest.h> +#include <functional> #include <queue> 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 <process/testutils/d_test_stubs.h> #include <process/daemon.h> #include <cc/command_interpreter.h> -#include <boost/bind.hpp> +#include <functional> 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 <exceptions/exceptions.h> #include <util/process_spawn.h> #include <util/signal_set.h> -#include <boost/bind.hpp> +#include <functional> #include <map> #include <signal.h> #include <stdlib.h> @@ -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 <exceptions/exceptions.h> -#include <boost/function.hpp> #include <boost/noncopyable.hpp> #include <boost/shared_ptr.hpp> +#include <functional> #include <set> #include <list> #include <pthread.h> @@ -44,14 +44,14 @@ class SignalSet; /// @brief Pointer to the @c isc::util::SignalSet. typedef boost::shared_ptr<SignalSet> SignalSetPtr; /// @brief Pointer to the signal handling function. -typedef boost::function<void(int signum)> SignalHandler; +typedef std::function<void(int signum)> 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<bool(int signum)> BoolSignalHandler; +typedef std::function<bool(int signum)> 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 <config.h> #include <util/state_model.h> -#include <boost/bind.hpp> #include <string> 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 <exceptions/exceptions.h> #include <util/labeled_value.h> -#include <boost/function.hpp> #include <boost/shared_ptr.hpp> +#include <functional> #include <map> #include <mutex> #include <string> @@ -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<void()> StateHandler; +typedef std::function<void()> 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 <config.h> #include <util/signal_set.h> -#include <boost/bind.hpp> #include <boost/shared_ptr.hpp> #include <gtest/gtest.h> #include <signal.h> @@ -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 <util/state_model.h> -#include <boost/function.hpp> -#include <boost/bind.hpp> #include <gtest/gtest.h> 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 <util/watched_thread.h> -#include <boost/bind.hpp> #include <gtest/gtest.h> -#include <unistd.h> #include <atomic> +#include <functional> +#include <unistd.h> 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<void()>& thread_main) { +WatchedThread::start(const std::function<void()>& 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 <util/watch_socket.h> #include <boost/shared_ptr.hpp> -#include <boost/function.hpp> +#include <functional> #include <mutex> #include <thread> @@ -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<void()>& thread_main); + void start(const std::function<void()>& thread_main); /// @brief Returns true if the thread is running bool isRunning() { |