diff --git a/bindings/c/library.cpp b/bindings/c/library.cpp index c438b20d3..5e9a30dbe 100644 --- a/bindings/c/library.cpp +++ b/bindings/c/library.cpp @@ -34,7 +34,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/session_status.hpp" #include "libtorrent/magnet_uri.hpp" #include "libtorrent/torrent_handle.hpp" -#include #include #include @@ -60,7 +59,8 @@ namespace int add_handle(libtorrent::torrent_handle const& h) { std::vector::iterator i = std::find_if(handles.begin() - , handles.end(), !std::bind(&libtorrent::torrent_handle::is_valid, _1)); + , handles.end() + , [](libtorrent::torrent_handle const& h) { return !h.is_valid(); }); if (i != handles.end()) { *i = h; diff --git a/bindings/python/src/create_torrent.cpp b/bindings/python/src/create_torrent.cpp index 37d819bfa..52f33c112 100644 --- a/bindings/python/src/create_torrent.cpp +++ b/bindings/python/src/create_torrent.cpp @@ -29,23 +29,18 @@ namespace c.set_file_hash(f, sha1_hash(b.arr)); } - void call_python_object(boost::python::object const& obj, int i) - { - obj(i); - } - #ifndef BOOST_NO_EXCEPTIONS void set_piece_hashes_callback(create_torrent& c, std::string const& p , boost::python::object cb) { - set_piece_hashes(c, p, boost::bind(call_python_object, cb, _1)); + set_piece_hashes(c, p, [&](int const i) { cb(i); }); } #else void set_piece_hashes_callback(create_torrent& c, std::string const& p , boost::python::object cb) { error_code ec; - set_piece_hashes(c, p, boost::bind(call_python_object, cb, _1), ec); + set_piece_hashes(c, p, [&](int const i) { cb(i); }, ec); } void set_piece_hashes0(create_torrent& c, std::string const & s) @@ -105,15 +100,10 @@ namespace { return FileIter(self, self.num_files()); } #endif - bool call_python_object2(boost::python::object& obj, std::string const& i) - { - return obj(i); - } - void add_files_callback(file_storage& fs, std::string const& file , boost::python::object cb, std::uint32_t flags) { - add_files(fs, file, boost::bind(&call_python_object2, cb, _1), flags); + add_files(fs, file, [&](std::string const& i) { return cb(i); }, flags); } } diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index c5ab4cf32..1fa1cb8ef 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -470,8 +470,9 @@ namespace TORRENT_ASSERT(public_key.size() == 32); std::array key; std::copy(public_key.begin(), public_key.end(), key.begin()); - ses.dht_put_item(key, boost::bind(&put_string, _1, _2, _3, _4 - , public_key, private_key, data) + ses.dht_put_item(key, [&](entry& e, std::array& sig, std::uint64_t& seq + , std::string const& salt) { put_string(e, sig, seq, salt + , public_key, private_key, data); } , salt); } #endif diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 84cbe778c..6a13299ee 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -44,10 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" - -#include #include - #include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/buffer.hpp" @@ -430,7 +427,7 @@ private: // (outgoing only) synchronize verification constant with // remote peer, this will hold rc4_decrypt(vc). Destroyed // after the sync step. - boost::scoped_array m_sync_vc; + std::unique_ptr m_sync_vc; // (incoming only) synchronize hash with remote peer, holds // the sync hash (hash("req1",secret)). Destroyed after the diff --git a/simulation/setup_dht.cpp b/simulation/setup_dht.cpp index b56fcf380..b4281a537 100644 --- a/simulation/setup_dht.cpp +++ b/simulation/setup_dht.cpp @@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/node.hpp" #include "libtorrent/kademlia/dht_observer.hpp" #include "setup_transfer.hpp" -#include #include // for unique_ptr #include #include "libtorrent/socket_io.hpp" // print_endpoint @@ -108,7 +107,8 @@ struct dht_node final : lt::dht::udp_socket_interface udp::socket::non_blocking_io ioc(true); sock().io_control(ioc); sock().async_receive_from(asio::mutable_buffers_1(m_buffer, sizeof(m_buffer)) - , m_ep, boost::bind(&dht_node::on_read, this, _1, _2)); + , m_ep, [&](lt::error_code const& ec, std::size_t bytes_transferred) + { this->on_read(ec, bytes_transferred); }); } #if LIBSIMULATOR_USE_MOVE @@ -161,7 +161,8 @@ struct dht_node final : lt::dht::udp_socket_interface dht().incoming(m); sock().async_receive_from(asio::mutable_buffers_1(m_buffer, sizeof(m_buffer)) - , m_ep, boost::bind(&dht_node::on_read, this, _1, _2)); + , m_ep, [&](lt::error_code const& ec, std::size_t bytes_transferred) + { this->on_read(ec, bytes_transferred); }); } bool has_quota() override { return true; } diff --git a/simulation/setup_swarm.cpp b/simulation/setup_swarm.cpp index d5525de27..41e9f4350 100644 --- a/simulation/setup_swarm.cpp +++ b/simulation/setup_swarm.cpp @@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/settings_pack.hpp" #include "libtorrent/ip_filter.hpp" #include "libtorrent/alert_types.hpp" -#include #include #include "settings.hpp" diff --git a/simulation/test_dht.cpp b/simulation/test_dht.cpp index af5d57c7a..f5bb11870 100644 --- a/simulation/test_dht.cpp +++ b/simulation/test_dht.cpp @@ -48,7 +48,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/ed25519.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/kademlia/item.hpp" -#include namespace lt = libtorrent; diff --git a/simulation/test_utp.cpp b/simulation/test_utp.cpp index f4a038843..eb79c7371 100644 --- a/simulation/test_utp.cpp +++ b/simulation/test_utp.cpp @@ -34,7 +34,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/settings_pack.hpp" #include "libtorrent/alert_types.hpp" #include "libtorrent/time.hpp" // for clock_type -#include #include "test.hpp" #include "setup_swarm.hpp" diff --git a/src/enum_net.cpp b/src/enum_net.cpp index 801726550..32ac98de0 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -56,7 +56,6 @@ POSSIBILITY OF SUCH DAMAGE. #if TORRENT_USE_SYSCTL #include #include -#include #endif #if TORRENT_USE_GETIPFORWARDTABLE || TORRENT_USE_GETADAPTERSADDRESSES @@ -866,7 +865,7 @@ namespace libtorrent return std::vector(); } - boost::scoped_array buf(new (std::nothrow) char[needed]); + std::unique_ptr buf(new (std::nothrow) char[needed]); if (buf.get() == nullptr) { ec = boost::asio::error::no_memory; diff --git a/src/part_file.cpp b/src/part_file.cpp index 973da165f..060e25ffe 100644 --- a/src/part_file.cpp +++ b/src/part_file.cpp @@ -65,11 +65,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/io.hpp" #include "libtorrent/assert.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" -// TODO: 3 use std::unique_ptr -#include -#include "libtorrent/aux_/disable_warnings_pop.hpp" - namespace { // round up to even kilobyte @@ -98,7 +93,7 @@ namespace libtorrent if (!ec) { // parse header - boost::scoped_array header(new std::uint32_t[m_header_size]); + std::unique_ptr header(new std::uint32_t[m_header_size]); file::iovec_t b = {header.get(), size_t(m_header_size) }; int n = m_file.readv(0, &b, 1, ec); if (ec) return; @@ -308,7 +303,7 @@ namespace libtorrent int piece = offset / m_piece_size; int const end = ((offset + size) + m_piece_size - 1) / m_piece_size; - boost::scoped_array buf; + std::unique_ptr buf; std::int64_t piece_offset = offset - std::int64_t(piece) * m_piece_size; std::int64_t file_offset = 0; @@ -397,7 +392,7 @@ namespace libtorrent open_file(file::read_write, ec); if (ec) return; - boost::scoped_array header(new std::uint32_t[m_header_size]); + std::unique_ptr header(new std::uint32_t[m_header_size]); using namespace libtorrent::detail;