From 8c8c3d5587193b635c164b7bfdce6fde4fe481f1 Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 12 Aug 2016 21:31:55 -0400 Subject: [PATCH] replace boost::function with std::function --- examples/simple_client.cpp | 2 +- include/libtorrent/add_torrent_params.hpp | 4 +- include/libtorrent/alert_manager.hpp | 9 +++-- include/libtorrent/aux_/session_call.hpp | 1 - include/libtorrent/aux_/session_impl.hpp | 10 ++--- include/libtorrent/aux_/session_interface.hpp | 5 ++- include/libtorrent/block_cache.hpp | 2 +- include/libtorrent/broadcast_socket.hpp | 2 +- include/libtorrent/create_torrent.hpp | 10 ++--- include/libtorrent/disk_buffer_pool.hpp | 15 ++++--- include/libtorrent/disk_interface.hpp | 38 +++++++++--------- include/libtorrent/disk_io_job.hpp | 2 +- include/libtorrent/disk_io_thread.hpp | 38 +++++++++--------- include/libtorrent/file.hpp | 2 +- include/libtorrent/http_connection.hpp | 8 ++-- include/libtorrent/kademlia/dht_tracker.hpp | 16 ++++---- .../libtorrent/kademlia/direct_request.hpp | 6 +-- include/libtorrent/kademlia/find_data.hpp | 2 +- include/libtorrent/kademlia/get_item.hpp | 2 +- include/libtorrent/kademlia/get_peers.hpp | 2 +- include/libtorrent/kademlia/node.hpp | 18 ++++----- include/libtorrent/kademlia/put_data.hpp | 2 +- include/libtorrent/lsd.hpp | 4 +- include/libtorrent/natpmp.hpp | 4 +- include/libtorrent/proxy_base.hpp | 2 +- include/libtorrent/resolver.hpp | 9 +++-- include/libtorrent/resolver_interface.hpp | 10 ++--- include/libtorrent/session_handle.hpp | 10 ++--- include/libtorrent/ssl_stream.hpp | 2 +- include/libtorrent/torrent.hpp | 2 +- include/libtorrent/torrent_handle.hpp | 4 +- include/libtorrent/tracker_manager.hpp | 6 +-- include/libtorrent/upnp.hpp | 11 ++--- include/libtorrent/utp_socket_manager.hpp | 11 ++--- include/libtorrent/utp_stream.hpp | 16 +++----- include/libtorrent/xml_parse.hpp | 8 +--- simulation/setup_swarm.cpp | 4 +- simulation/test_dht_rate_limit.cpp | 2 +- simulation/test_web_seed.cpp | 2 +- src/alert_manager.cpp | 2 +- src/block_cache.cpp | 2 +- src/create_torrent.cpp | 14 +++---- src/disk_buffer_pool.cpp | 2 +- src/disk_io_thread.cpp | 32 +++++++-------- src/file_pool.cpp | 11 ++--- src/http_connection.cpp | 4 +- src/kademlia/dht_tracker.cpp | 30 +++++++------- src/kademlia/get_peers.cpp | 4 +- src/kademlia/node.cpp | 20 +++++----- src/lsd.cpp | 2 +- src/session.cpp | 2 +- src/session_handle.cpp | 8 ++-- src/session_impl.cpp | 40 +++++++++---------- src/torrent.cpp | 14 +++---- src/torrent_handle.cpp | 2 +- src/tracker_manager.cpp | 4 +- src/udp_socket.cpp | 2 +- src/upnp.cpp | 22 +++++----- src/utp_stream.cpp | 15 ++----- src/xml_parse.cpp | 2 +- test/bittorrent_peer.cpp | 2 +- test/bittorrent_peer.hpp | 6 +-- test/setup_transfer.cpp | 2 +- test/test_alert_manager.cpp | 2 +- test/test_bandwidth_limiter.cpp | 9 +++-- test/test_fast_extension.cpp | 6 +-- test/test_storage.cpp | 8 ++-- test/test_torrent.cpp | 14 +++---- test/test_upnp.cpp | 2 +- test/test_xml.cpp | 6 +-- 70 files changed, 283 insertions(+), 311 deletions(-) diff --git a/examples/simple_client.cpp b/examples/simple_client.cpp index f2bc8389b..eae8101a6 100644 --- a/examples/simple_client.cpp +++ b/examples/simple_client.cpp @@ -70,7 +70,7 @@ int main(int argc, char* argv[]) } add_torrent_params p; p.save_path = "./"; - p.ti = boost::make_shared(std::string(argv[1]), boost::ref(ec), 0); + p.ti = boost::make_shared(std::string(argv[1]), std::ref(ec), 0); if (ec) { std::fprintf(stderr, "%s\n", ec.message().c_str()); diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index 13fd212f3..8f4b7eae5 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -36,10 +36,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "libtorrent/aux_/disable_warnings_push.hpp" #include -#include #include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/storage_defs.hpp" @@ -343,7 +343,7 @@ namespace libtorrent // to avoid race conditions. For instance it may be important to have the // plugin catch events that happen very early on after the torrent is // created. - std::vector(torrent_handle const&, void*)>> + std::vector(torrent_handle const&, void*)>> extensions; // the default tracker id to be used when announcing to trackers. By diff --git a/include/libtorrent/alert_manager.hpp b/include/libtorrent/alert_manager.hpp index 9f1d5d1eb..f6ec105e8 100644 --- a/include/libtorrent/alert_manager.hpp +++ b/include/libtorrent/alert_manager.hpp @@ -40,15 +40,16 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" -#include #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + +#include #include #include // for std::forward #include #include -#include "libtorrent/aux_/disable_warnings_pop.hpp" namespace libtorrent { @@ -113,7 +114,7 @@ namespace libtorrent { int alert_queue_size_limit() const { return m_queue_size_limit; } int set_alert_queue_size_limit(int queue_size_limit_); - void set_notify_function(boost::function const& fun); + void set_notify_function(std::function const& fun); #ifndef TORRENT_DISABLE_EXTENSIONS void add_extension(boost::shared_ptr ext); @@ -138,7 +139,7 @@ namespace libtorrent { // That call will drain every alert in one atomic operation and this // notification function will be called again the next time an alert is // posted to the queue - boost::function m_notify; + std::function m_notify; // this is either 0 or 1, it indicates which m_alerts and m_allocations // the alert_manager is allowed to use right now. This is swapped when diff --git a/include/libtorrent/aux_/session_call.hpp b/include/libtorrent/aux_/session_call.hpp index 66977f6dc..774c609f7 100644 --- a/include/libtorrent/aux_/session_call.hpp +++ b/include/libtorrent/aux_/session_call.hpp @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/aux_/session_impl.hpp" -#include #include namespace libtorrent { namespace aux { diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 2d8419878..a281efb80 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -112,7 +112,7 @@ namespace libtorrent struct bencode_map_entry; - typedef boost::function dht_extension_handler_t; struct listen_socket_t @@ -217,7 +217,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_EXTENSIONS using ext_function_t - = boost::function(torrent_handle const&, void*)>; + = std::function(torrent_handle const&, void*)>; struct session_plugin_wrapper : plugin { @@ -229,7 +229,7 @@ namespace libtorrent ext_function_t m_f; }; - void add_extension(boost::function( + void add_extension(std::function( torrent_handle const&, void*)> ext); void add_ses_extension(boost::shared_ptr ext); #endif @@ -349,7 +349,7 @@ namespace libtorrent void dht_put_immutable_item(entry const& data, sha1_hash target); void dht_put_mutable_item(std::array key - , boost::function& + , std::function& , std::uint64_t&, std::string const&)> cb , std::string salt = std::string()); @@ -447,7 +447,7 @@ namespace libtorrent void remove_torrent_impl(boost::shared_ptr tptr, int options) override; void get_torrent_status(std::vector* ret - , boost::function const& pred + , std::function const& pred , std::uint32_t flags) const; void refresh_torrent_status(std::vector* ret , std::uint32_t flags) const; diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index 731173e53..0a02ba7ec 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -39,6 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/io_service.hpp" #include "libtorrent/disk_buffer_holder.hpp" +#include + #ifndef TORRENT_DISABLE_DHT #include "libtorrent/socket.hpp" #endif @@ -48,7 +50,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" #include -#include #ifndef TORRENT_DISABLE_LOGGING #include @@ -155,7 +156,7 @@ namespace libtorrent { namespace aux virtual io_service& get_io_service() = 0; virtual resolver_interface& get_resolver() = 0; - typedef boost::function const&)> + typedef std::function const&)> callback_t; // TODO: 2 remove this. There's already get_resolver() diff --git a/include/libtorrent/block_cache.hpp b/include/libtorrent/block_cache.hpp index a6ec108fd..b49a7c32b 100644 --- a/include/libtorrent/block_cache.hpp +++ b/include/libtorrent/block_cache.hpp @@ -338,7 +338,7 @@ namespace libtorrent struct TORRENT_EXTRA_EXPORT block_cache : disk_buffer_pool { block_cache(int block_size, io_service& ios - , boost::function const& trigger_trim); + , std::function const& trigger_trim); private: diff --git a/include/libtorrent/broadcast_socket.hpp b/include/libtorrent/broadcast_socket.hpp index f3713dbd1..1b4d1e098 100644 --- a/include/libtorrent/broadcast_socket.hpp +++ b/include/libtorrent/broadcast_socket.hpp @@ -61,7 +61,7 @@ namespace libtorrent // determines if the operating system supports IPv6 TORRENT_EXTRA_EXPORT bool supports_ipv6(); - typedef boost::function receive_handler_t; class TORRENT_EXTRA_EXPORT broadcast_socket diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index f931fc329..0f4b2488e 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -395,7 +395,7 @@ namespace libtorrent // The ``flags`` argument should be the same as the flags passed to the `create_torrent`_ // constructor. TORRENT_EXPORT void add_files(file_storage& fs, std::string const& file - , boost::function p, std::uint32_t flags = 0); + , std::function p, std::uint32_t flags = 0); TORRENT_EXPORT void add_files(file_storage& fs, std::string const& file , std::uint32_t flags = 0); @@ -409,7 +409,7 @@ namespace libtorrent // The overloads that don't take an ``error_code&`` may throw an exception in case of a // file error, the other overloads sets the error code to reflect the error, if any. TORRENT_EXPORT void set_piece_hashes(create_torrent& t, std::string const& p - , boost::function const& f, error_code& ec); + , std::function const& f, error_code& ec); inline void set_piece_hashes(create_torrent& t, std::string const& p, error_code& ec) { set_piece_hashes(t, p, detail::nop, ec); @@ -440,7 +440,7 @@ namespace libtorrent TORRENT_DEPRECATED TORRENT_EXPORT void add_files(file_storage& fs, std::wstring const& wfile - , boost::function p, std::uint32_t flags = 0); + , std::function p, std::uint32_t flags = 0); TORRENT_DEPRECATED TORRENT_EXPORT void add_files(file_storage& fs, std::wstring const& wfile @@ -448,11 +448,11 @@ namespace libtorrent TORRENT_DEPRECATED TORRENT_EXPORT void set_piece_hashes(create_torrent& t, std::wstring const& p - , boost::function f, error_code& ec); + , std::function f, error_code& ec); TORRENT_EXPORT void set_piece_hashes_deprecated(create_torrent& t , std::wstring const& p - , boost::function f, error_code& ec); + , std::function f, error_code& ec); #ifndef BOOST_NO_EXCEPTIONS template diff --git a/include/libtorrent/disk_buffer_pool.hpp b/include/libtorrent/disk_buffer_pool.hpp index 54711ec6f..e4391e6c8 100644 --- a/include/libtorrent/disk_buffer_pool.hpp +++ b/include/libtorrent/disk_buffer_pool.hpp @@ -36,11 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" - -#include -#include #include -#include #include #ifndef TORRENT_DISABLE_POOL_ALLOCATOR @@ -48,11 +44,14 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif +#include "libtorrent/aux_/disable_warnings_pop.hpp" + #if TORRENT_USE_INVARIANT_CHECKS #include #endif - -#include "libtorrent/aux_/disable_warnings_pop.hpp" +#include +#include +#include #include "libtorrent/io_service_fwd.hpp" #include "libtorrent/file.hpp" // for iovec_t @@ -66,7 +65,7 @@ namespace libtorrent struct TORRENT_EXTRA_EXPORT disk_buffer_pool : boost::noncopyable { disk_buffer_pool(int block_size, io_service& ios - , boost::function const& trigger_trim); + , std::function const& trigger_trim); ~disk_buffer_pool(); #if TORRENT_USE_ASSERTS @@ -125,7 +124,7 @@ namespace libtorrent std::vector> m_observers; // callback used to tell the cache it needs to free up some blocks - boost::function m_trigger_cache_trim; + std::function m_trigger_cache_trim; // set to true to throttle more allocations bool m_exceeded_max_size; diff --git a/include/libtorrent/disk_interface.hpp b/include/libtorrent/disk_interface.hpp index 06eeff274..ff2493edc 100644 --- a/include/libtorrent/disk_interface.hpp +++ b/include/libtorrent/disk_interface.hpp @@ -53,50 +53,50 @@ namespace libtorrent struct TORRENT_EXTRA_EXPORT disk_interface { virtual void async_read(piece_manager* storage, peer_request const& r - , boost::function handler, void* requester + , std::function handler, void* requester , int flags = 0) = 0; virtual void async_write(piece_manager* storage, peer_request const& r , disk_buffer_holder buffer - , boost::function handler + , std::function handler , int flags = 0) = 0; virtual void async_hash(piece_manager* storage, int piece, int flags - , boost::function handler, void* requester) = 0; + , std::function handler, void* requester) = 0; virtual void async_move_storage(piece_manager* storage, std::string const& p, int flags - , boost::function handler) = 0; + , std::function handler) = 0; virtual void async_release_files(piece_manager* storage - , boost::function handler - = boost::function()) = 0; + , std::function handler + = std::function()) = 0; virtual void async_check_files(piece_manager* storage , add_torrent_params const* resume_data , std::vector& links - , boost::function handler) = 0; + , std::function handler) = 0; #ifndef TORRENT_NO_DEPRECATE virtual void async_cache_piece(piece_manager* storage, int piece - , boost::function handler) = 0; + , std::function handler) = 0; virtual void async_finalize_file(piece_manager*, int file - , boost::function handler - = boost::function()) = 0; + , std::function handler + = std::function()) = 0; #endif virtual void async_flush_piece(piece_manager* storage, int piece - , boost::function handler - = boost::function()) = 0; + , std::function handler + = std::function()) = 0; virtual void async_stop_torrent(piece_manager* storage - , boost::function handler)= 0; + , std::function handler)= 0; virtual void async_rename_file(piece_manager* storage, int index, std::string const& name - , boost::function handler) = 0; + , std::function handler) = 0; virtual void async_delete_files(piece_manager* storage, int options - , boost::function handler) = 0; + , std::function handler) = 0; virtual void async_set_file_priority(piece_manager* storage , std::vector const& prio - , boost::function handler) = 0; + , std::function handler) = 0; virtual void async_load_torrent(add_torrent_params* params - , boost::function handler) = 0; + , std::function handler) = 0; virtual void async_tick_torrent(piece_manager* storage - , boost::function handler) = 0; + , std::function handler) = 0; virtual void clear_read_cache(piece_manager* storage) = 0; virtual void async_clear_piece(piece_manager* storage, int index - , boost::function handler) = 0; + , std::function handler) = 0; virtual void clear_piece(piece_manager* storage, int index) = 0; virtual void update_stats_counters(counters& c) const = 0; diff --git a/include/libtorrent/disk_io_job.hpp b/include/libtorrent/disk_io_job.hpp index 66f68aaac..f5c478bb0 100644 --- a/include/libtorrent/disk_io_job.hpp +++ b/include/libtorrent/disk_io_job.hpp @@ -164,7 +164,7 @@ namespace libtorrent boost::shared_ptr storage; // this is called when operation completes - boost::function callback; + std::function callback; // the error code from the file operation // on error, this also contains the path of the diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 9ae74aaf0..183b9212d 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -300,50 +300,50 @@ namespace libtorrent void abort(bool wait); void async_read(piece_manager* storage, peer_request const& r - , boost::function handler, void* requester + , std::function handler, void* requester , int flags = 0) override; void async_write(piece_manager* storage, peer_request const& r , disk_buffer_holder buffer - , boost::function handler + , std::function handler , int flags = 0) override; void async_hash(piece_manager* storage, int piece, int flags - , boost::function handler, void* requester) override; + , std::function handler, void* requester) override; void async_move_storage(piece_manager* storage, std::string const& p, int flags - , boost::function handler) override; + , std::function handler) override; void async_release_files(piece_manager* storage - , boost::function handler - = boost::function()) override; + , std::function handler + = std::function()) override; void async_delete_files(piece_manager* storage, int options - , boost::function handler) override; + , std::function handler) override; void async_check_files(piece_manager* storage , add_torrent_params const* resume_data , std::vector& links - , boost::function handler) override; + , std::function handler) override; void async_rename_file(piece_manager* storage, int index, std::string const& name - , boost::function handler) override; + , std::function handler) override; void async_stop_torrent(piece_manager* storage - , boost::function handler) override; + , std::function handler) override; #ifndef TORRENT_NO_DEPRECATE void async_cache_piece(piece_manager* storage, int piece - , boost::function handler) override; + , std::function handler) override; void async_finalize_file(piece_manager* storage, int file - , boost::function handler - = boost::function()) override; + , std::function handler + = std::function()) override; #endif void async_flush_piece(piece_manager* storage, int piece - , boost::function handler - = boost::function()) override; + , std::function handler + = std::function()) override; void async_set_file_priority(piece_manager* storage , std::vector const& prio - , boost::function handler) override; + , std::function handler) override; void async_load_torrent(add_torrent_params* params - , boost::function handler) override; + , std::function handler) override; void async_tick_torrent(piece_manager* storage - , boost::function handler) override; + , std::function handler) override; void clear_read_cache(piece_manager* storage) override; void async_clear_piece(piece_manager* storage, int index - , boost::function handler) override; + , std::function handler) override; // this is not asynchronous and requires that the piece does not // have any pending buffers. It's meant to be used for pieces that // were just read and hashed and failed the hash check. diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index 41274ca32..b31aa7fe3 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include "libtorrent/config.hpp" #include "libtorrent/string_view.hpp" @@ -43,7 +44,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include #ifdef TORRENT_WINDOWS // windows part diff --git a/include/libtorrent/http_connection.hpp b/include/libtorrent/http_connection.hpp index 176026cc5..ea4bdcfb4 100644 --- a/include/libtorrent/http_connection.hpp +++ b/include/libtorrent/http_connection.hpp @@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" -#include #include #include @@ -45,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" +#include #include #include @@ -65,12 +65,12 @@ struct resolver_interface; const int default_max_bottled_buffer_size = 2 * 1024 * 1024; -typedef boost::function http_handler; -typedef boost::function http_connect_handler; +typedef std::function http_connect_handler; -typedef boost::function&)> http_filter_handler; +typedef std::function&)> http_filter_handler; // when bottled, the last two arguments to the handler // will always be 0 diff --git a/include/libtorrent/kademlia/dht_tracker.hpp b/include/libtorrent/kademlia/dht_tracker.hpp index 0e26826f0..316f28cfa 100644 --- a/include/libtorrent/kademlia/dht_tracker.hpp +++ b/include/libtorrent/kademlia/dht_tracker.hpp @@ -93,35 +93,35 @@ namespace libtorrent { namespace dht enum flags_t { flag_seed = 1, flag_implied_port = 2 }; void get_peers(sha1_hash const& ih - , boost::function const&)> f); + , std::function const&)> f); void announce(sha1_hash const& ih, int listen_port, int flags - , boost::function const&)> f); + , std::function const&)> f); void get_item(sha1_hash const& target - , boost::function cb); + , std::function cb); // key is a 32-byte binary string, the public key to look up. // the salt is optional void get_item(public_key const& key - , boost::function cb + , std::function cb , std::string salt = std::string()); // for immutable_item. // the callback function will be called when put operation is done. // the int parameter indicates the success numbers of put operation. void put_item(entry const& data - , boost::function cb); + , std::function cb); // for mutable_item. // the data_cb will be called when we get authoritative mutable_item, // the cb is same as put immutable_item. void put_item(public_key const& key - , boost::function cb - , boost::function data_cb, std::string salt = std::string()); + , std::function cb + , std::function data_cb, std::string salt = std::string()); // send an arbitrary DHT request directly to a node void direct_request(udp::endpoint ep, entry& e - , boost::function f); + , std::function f); #ifndef TORRENT_NO_DEPRECATE void dht_status(session_status& s); diff --git a/include/libtorrent/kademlia/direct_request.hpp b/include/libtorrent/kademlia/direct_request.hpp index 7c5945d86..380ccbdd9 100644 --- a/include/libtorrent/kademlia/direct_request.hpp +++ b/include/libtorrent/kademlia/direct_request.hpp @@ -42,7 +42,7 @@ namespace libtorrent { namespace dht struct direct_traversal : traversal_algorithm { - typedef boost::function message_callback; + typedef std::function message_callback; direct_traversal(node& node , node_id target @@ -55,10 +55,10 @@ struct direct_traversal : traversal_algorithm void invoke_cb(msg const& m) { - if (!m_cb.empty()) + if (m_cb) { m_cb(m); - m_cb.clear(); + m_cb = nullptr; done(); } } diff --git a/include/libtorrent/kademlia/find_data.hpp b/include/libtorrent/kademlia/find_data.hpp index ccd33e7df..6762adc88 100644 --- a/include/libtorrent/kademlia/find_data.hpp +++ b/include/libtorrent/kademlia/find_data.hpp @@ -63,7 +63,7 @@ class node; struct find_data : traversal_algorithm { - typedef boost::function > const&)> nodes_callback; + typedef std::function > const&)> nodes_callback; find_data(node& node, node_id target , nodes_callback const& ncallback); diff --git a/include/libtorrent/kademlia/get_item.hpp b/include/libtorrent/kademlia/get_item.hpp index 1ae56cfab..2c92b915d 100644 --- a/include/libtorrent/kademlia/get_item.hpp +++ b/include/libtorrent/kademlia/get_item.hpp @@ -43,7 +43,7 @@ namespace libtorrent { namespace dht class get_item : public find_data { public: - typedef boost::function data_callback; + typedef std::function data_callback; void got_data(bdecode_node const& v, public_key const& pk, diff --git a/include/libtorrent/kademlia/get_peers.hpp b/include/libtorrent/kademlia/get_peers.hpp index e71265c64..787b6389b 100644 --- a/include/libtorrent/kademlia/get_peers.hpp +++ b/include/libtorrent/kademlia/get_peers.hpp @@ -40,7 +40,7 @@ namespace libtorrent { namespace dht struct get_peers : find_data { - typedef boost::function const&)> data_callback; + typedef std::function const&)> data_callback; void got_peers(std::vector const& peers); diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index c2993dadd..eae69693e 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -141,22 +141,22 @@ public: enum flags_t { flag_seed = 1, flag_implied_port = 2 }; void get_peers(sha1_hash const& info_hash - , boost::function const&)> dcallback - , boost::function > const&)> ncallback + , std::function const&)> dcallback + , std::function > const&)> ncallback , bool noseeds); void announce(sha1_hash const& info_hash, int listen_port, int flags - , boost::function const&)> f); + , std::function const&)> f); void direct_request(udp::endpoint ep, entry& e - , boost::function f); + , std::function f); - void get_item(sha1_hash const& target, boost::function f); - void get_item(public_key const& pk, std::string const& salt, boost::function f); + void get_item(sha1_hash const& target, std::function f); + void get_item(public_key const& pk, std::string const& salt, std::function f); - void put_item(sha1_hash const& target, entry const& data, boost::function f); + void put_item(sha1_hash const& target, entry const& data, std::function f); void put_item(public_key const& pk, std::string const& salt - , boost::function f - , boost::function data_cb); + , std::function f + , std::function data_cb); bool verify_token(string_view token, sha1_hash const& info_hash , udp::endpoint const& addr) const; diff --git a/include/libtorrent/kademlia/put_data.hpp b/include/libtorrent/kademlia/put_data.hpp index c4ab76436..b8c828272 100644 --- a/include/libtorrent/kademlia/put_data.hpp +++ b/include/libtorrent/kademlia/put_data.hpp @@ -53,7 +53,7 @@ class node; struct put_data: traversal_algorithm { - typedef boost::function put_callback; + typedef std::function put_callback; put_data(node& node, put_callback const& callback); diff --git a/include/libtorrent/lsd.hpp b/include/libtorrent/lsd.hpp index e1e9738b7..a75eaefb1 100644 --- a/include/libtorrent/lsd.hpp +++ b/include/libtorrent/lsd.hpp @@ -54,9 +54,9 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -typedef boost::function peer_callback_t; +typedef std::function peer_callback_t; #ifndef TORRENT_DISABLE_LOGGING -typedef boost::function log_callback_t; +typedef std::function log_callback_t; #endif class lsd : public boost::enable_shared_from_this diff --git a/include/libtorrent/natpmp.hpp b/include/libtorrent/natpmp.hpp index ac6994bc7..58e2ef21e 100644 --- a/include/libtorrent/natpmp.hpp +++ b/include/libtorrent/natpmp.hpp @@ -55,8 +55,8 @@ namespace libtorrent // int: port mapping index // int: external port // std::string: error message -typedef boost::function portmap_callback_t; -typedef boost::function log_callback_t; +typedef std::function portmap_callback_t; +typedef std::function log_callback_t; struct TORRENT_EXTRA_EXPORT natpmp : boost::enable_shared_from_this diff --git a/include/libtorrent/proxy_base.hpp b/include/libtorrent/proxy_base.hpp index 8bed55e6e..54a2fb13a 100644 --- a/include/libtorrent/proxy_base.hpp +++ b/include/libtorrent/proxy_base.hpp @@ -50,7 +50,7 @@ class proxy_base : boost::noncopyable { public: - typedef boost::function handler_type; + typedef std::function handler_type; typedef tcp::socket next_layer_type; typedef tcp::socket::lowest_layer_type lowest_layer_type; diff --git a/include/libtorrent/resolver.hpp b/include/libtorrent/resolver.hpp index 3553c97e5..4ade1de03 100644 --- a/include/libtorrent/resolver.hpp +++ b/include/libtorrent/resolver.hpp @@ -36,12 +36,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" #include -#include -#include -#include #include "libtorrent/aux_/disable_warnings_pop.hpp" +#include +#include +#include + #include "libtorrent/error_code.hpp" #include "libtorrent/io_service.hpp" #include "libtorrent/socket.hpp" @@ -72,7 +73,7 @@ private: std::vector
addresses; }; - typedef boost::unordered_map cache_t; + using cache_t = std::unordered_map; cache_t m_cache; io_service& m_ios; diff --git a/include/libtorrent/resolver_interface.hpp b/include/libtorrent/resolver_interface.hpp index b410465c6..93c9d0f6c 100644 --- a/include/libtorrent/resolver_interface.hpp +++ b/include/libtorrent/resolver_interface.hpp @@ -34,21 +34,17 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_RESOLVER_INTERFACE_HPP_INCLUDE #include +#include + #include "libtorrent/error_code.hpp" #include "libtorrent/address.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" - namespace libtorrent { struct TORRENT_EXTRA_EXPORT resolver_interface { - typedef boost::function const&)> + typedef std::function const&)> callback_t; enum flags_t diff --git a/include/libtorrent/session_handle.hpp b/include/libtorrent/session_handle.hpp index 20576d38f..a31a75935 100644 --- a/include/libtorrent/session_handle.hpp +++ b/include/libtorrent/session_handle.hpp @@ -58,7 +58,7 @@ namespace libtorrent struct session_status; #endif - typedef boost::function& + typedef std::function& , error_code&)> user_load_function_t; struct TORRENT_EXPORT session_handle @@ -150,7 +150,7 @@ namespace libtorrent // Any torrent_status object whose ``handle`` member is not referring to // a valid torrent are ignored. void get_torrent_status(std::vector* ret - , boost::function const& pred + , std::function const& pred , std::uint32_t flags = 0) const; void refresh_torrent_status(std::vector* ret , std::uint32_t flags = 0) const; @@ -418,7 +418,7 @@ namespace libtorrent // the DHT works, it is natural to always do a lookup before storing and // calling the callback in between is convenient. void dht_put_item(std::array key - , boost::function& + , std::function& , std::uint64_t&, std::string const&)> cb , std::string salt = std::string()); @@ -479,7 +479,7 @@ namespace libtorrent // // // .. _`libtorrent plugins`: libtorrent_plugins.html - void add_extension(boost::function( + void add_extension(std::function( torrent_handle const&, void*)> ext); void add_extension(boost::shared_ptr ext); @@ -942,7 +942,7 @@ namespace libtorrent // It really should just notify the main application thread. void pop_alerts(std::vector* alerts); alert* wait_for_alert(time_duration max_wait); - void set_alert_notify(boost::function const& fun); + void set_alert_notify(std::function const& fun); #ifndef TORRENT_NO_DEPRECATE TORRENT_DEPRECATED diff --git a/include/libtorrent/ssl_stream.hpp b/include/libtorrent/ssl_stream.hpp index e9463aaa0..6fd4adf44 100644 --- a/include/libtorrent/ssl_stream.hpp +++ b/include/libtorrent/ssl_stream.hpp @@ -100,7 +100,7 @@ public: SSL* native_handle() { return m_sock.native_handle(); } #endif - typedef boost::function handler_type; + typedef std::function handler_type; template void async_connect(endpoint_type const& endpoint, Handler const& handler) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index fdb691d26..4e9d50629 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -300,7 +300,7 @@ namespace libtorrent #ifndef TORRENT_DISABLE_EXTENSIONS void add_extension(boost::shared_ptr); void remove_extension(boost::shared_ptr); - void add_extension_fun(boost::function(torrent_handle const&, void*)> const& ext + void add_extension_fun(std::function(torrent_handle const&, void*)> const& ext , void* userdata); void notify_extension_add_peer(tcp::endpoint const& ip, int src, int flags); #endif diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index e0febfda7..4a93c56f1 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -37,10 +37,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include "libtorrent/aux_/disable_warnings_push.hpp" #include -#include #include #ifndef TORRENT_NO_DEPRECATE @@ -508,7 +508,7 @@ namespace libtorrent // pointer. The function is expected to return a shared pointer to // a torrent_plugin instance. void add_extension( - boost::function(torrent_handle const&, void*)> const& ext + std::function(torrent_handle const&, void*)> const& ext , void* userdata = 0); // ``set_metadata`` expects the *info* section of metadata. i.e. The diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index ac6537b25..3ff0320b2 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "libtorrent/aux_/disable_warnings_push.hpp" @@ -48,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #ifdef TORRENT_USE_OPENSSL #include @@ -341,10 +341,10 @@ namespace libtorrent { public: - typedef boost::function , error_code&, int)> send_fun_t; - typedef boost::function , error_code&, int)> send_fun_hostname_t; diff --git a/include/libtorrent/upnp.hpp b/include/libtorrent/upnp.hpp index 1261b5fbd..0c838ecae 100644 --- a/include/libtorrent/upnp.hpp +++ b/include/libtorrent/upnp.hpp @@ -42,11 +42,12 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/resolver.hpp" #include "libtorrent/debug.hpp" -#include -#include -#include +#include "libtorrent/aux_/disable_warnings_push.hpp" #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" + +#include #include namespace libtorrent @@ -101,8 +102,8 @@ namespace libtorrent // int: protocol (UDP, TCP) // std::string: error message // an empty string as error means success -typedef boost::function portmap_callback_t; -typedef boost::function log_callback_t; +typedef std::function portmap_callback_t; +typedef std::function log_callback_t; struct parse_state { diff --git a/include/libtorrent/utp_socket_manager.hpp b/include/libtorrent/utp_socket_manager.hpp index 7f088cf84..b301bda11 100644 --- a/include/libtorrent/utp_socket_manager.hpp +++ b/include/libtorrent/utp_socket_manager.hpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_UTP_SOCKET_MANAGER_HPP_INCLUDED #include +#include #include "libtorrent/socket_type.hpp" #include "libtorrent/session_status.hpp" @@ -41,12 +42,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/session_settings.hpp" #include "libtorrent/span.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" - namespace libtorrent { class utp_stream; @@ -55,11 +50,11 @@ namespace libtorrent struct utp_socket_manager final { - typedef boost::function , error_code&, int)> send_fun_t; - typedef boost::function const&)> + typedef std::function const&)> incoming_utp_callback_t; utp_socket_manager(send_fun_t const& send_fun diff --git a/include/libtorrent/utp_stream.hpp b/include/libtorrent/utp_stream.hpp index 84c24f39d..484d3029e 100644 --- a/include/libtorrent/utp_stream.hpp +++ b/include/libtorrent/utp_stream.hpp @@ -40,17 +40,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/error_code.hpp" #include "libtorrent/time.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - #include -#include -#include #ifndef BOOST_NO_EXCEPTIONS +#include "libtorrent/aux_/disable_warnings_push.hpp" #include -#endif - #include "libtorrent/aux_/disable_warnings_pop.hpp" +#endif namespace libtorrent { @@ -373,7 +369,7 @@ public: } void do_async_connect(endpoint_type const& ep - , boost::function const& handler); + , std::function const& handler); template void open(Protocol const&, error_code&) @@ -493,9 +489,9 @@ private: void cancel_handlers(error_code const&); - boost::function1 m_connect_handler; - boost::function2 m_read_handler; - boost::function2 m_write_handler; + std::function m_connect_handler; + std::function m_read_handler; + std::function m_write_handler; io_service& m_io_service; utp_socket_impl* m_impl; diff --git a/include/libtorrent/xml_parse.hpp b/include/libtorrent/xml_parse.hpp index 2975bdda2..1803e1f4f 100644 --- a/include/libtorrent/xml_parse.hpp +++ b/include/libtorrent/xml_parse.hpp @@ -33,11 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_XML_PARSE_HPP #define TORRENT_XML_PARSE_HPP -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" +#include #include "libtorrent/config.hpp" #include "libtorrent/assert.hpp" @@ -68,7 +64,7 @@ namespace libtorrent // name_len and val_len respectively // TODO: 3 use span<> for the callback TORRENT_EXTRA_EXPORT void xml_parse(span input - , boost::function callback); + , std::function callback); } diff --git a/simulation/setup_swarm.cpp b/simulation/setup_swarm.cpp index 725df70cf..065b5663a 100644 --- a/simulation/setup_swarm.cpp +++ b/simulation/setup_swarm.cpp @@ -287,7 +287,7 @@ void setup_swarm(int num_nodes std::snprintf(ep, sizeof(ep), "2000::%X%X", (i + 1) >> 8, (i + 1) & 0xff); ips.push_back(addr(ep)); io_service.push_back(boost::make_shared( - boost::ref(sim), ips)); + std::ref(sim), ips)); lt::settings_pack pack = default_settings; @@ -299,7 +299,7 @@ void setup_swarm(int num_nodes boost::shared_ptr ses = boost::make_shared(pack - , boost::ref(*io_service.back())); + , std::ref(*io_service.back())); init_session(*ses); nodes.push_back(ses); diff --git a/simulation/test_dht_rate_limit.cpp b/simulation/test_dht_rate_limit.cpp index df7edcf03..c61dcfb9c 100644 --- a/simulation/test_dht_rate_limit.cpp +++ b/simulation/test_dht_rate_limit.cpp @@ -111,7 +111,7 @@ TORRENT_TEST(dht_rate_limit) entry state; std::unique_ptr dht_storage(dht::dht_default_storage_constructor(dhtsett)); boost::shared_ptr dht = boost::make_shared( - &o, boost::ref(dht_ios), std::bind(&udp_socket::send, &sock, _1, _2, _3, _4) + &o, std::ref(dht_ios), std::bind(&udp_socket::send, &sock, _1, _2, _3, _4) , dhtsett, cnt, *dht_storage, state); bool stop = false; diff --git a/simulation/test_web_seed.cpp b/simulation/test_web_seed.cpp index 8ebfd480b..11f32e961 100644 --- a/simulation/test_web_seed.cpp +++ b/simulation/test_web_seed.cpp @@ -71,7 +71,7 @@ boost::shared_ptr create_torrent(file_storage& fs) bencode(out, tor); error_code ec; return boost::make_shared( - &tmp[0], tmp.size(), boost::ref(ec), 0); + &tmp[0], tmp.size(), std::ref(ec), 0); } // this is the general template for these tests. create the session with custom // settings (Settings), set up the test, by adding torrents with certain diff --git a/src/alert_manager.cpp b/src/alert_manager.cpp index 4cad7f945..428060bc6 100644 --- a/src/alert_manager.cpp +++ b/src/alert_manager.cpp @@ -93,7 +93,7 @@ namespace libtorrent #endif } - void alert_manager::set_notify_function(boost::function const& fun) + void alert_manager::set_notify_function(std::function const& fun) { std::unique_lock lock(m_mutex); m_notify = fun; diff --git a/src/block_cache.cpp b/src/block_cache.cpp index 0df3f9a31..3b7a40806 100644 --- a/src/block_cache.cpp +++ b/src/block_cache.cpp @@ -349,7 +349,7 @@ cached_piece_entry::~cached_piece_entry() } block_cache::block_cache(int block_size, io_service& ios - , boost::function const& trigger_trim) + , std::function const& trigger_trim) : disk_buffer_pool(block_size, ios, trigger_trim) , m_last_cache_op(cache_miss) , m_ghost_size(8) diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index 868d515b1..315856a99 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -117,7 +117,7 @@ namespace libtorrent } void add_files_impl(file_storage& fs, std::string const& p - , std::string const& l, boost::function pred, std::uint32_t flags) + , std::string const& l, std::function pred, std::uint32_t flags) { std::string f = combine_path(p, l); if (!pred(f)) return; @@ -167,7 +167,7 @@ namespace libtorrent void on_hash(disk_io_job const* j, create_torrent* t , boost::shared_ptr storage, disk_io_thread* iothread , int* piece_counter, int* completed_piece - , boost::function const* f, error_code* ec) + , std::function const* f, error_code* ec) { if (j->ret != 0) { @@ -200,7 +200,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE void add_files(file_storage& fs, std::wstring const& wfile - , boost::function p, std::uint32_t flags) + , std::function p, std::uint32_t flags) { std::string utf8; wchar_utf8(wfile, utf8); @@ -218,7 +218,7 @@ namespace libtorrent } void set_piece_hashes(create_torrent& t, std::wstring const& p - , boost::function f, error_code& ec) + , std::function f, error_code& ec) { std::string utf8; wchar_utf8(p, utf8); @@ -226,7 +226,7 @@ namespace libtorrent } void set_piece_hashes_deprecated(create_torrent& t, std::wstring const& p - , boost::function f, error_code& ec) + , std::function f, error_code& ec) { std::string utf8; wchar_utf8(p, utf8); @@ -236,7 +236,7 @@ namespace libtorrent #endif void add_files(file_storage& fs, std::string const& file - , boost::function p, std::uint32_t flags) + , std::function p, std::uint32_t flags) { add_files_impl(fs, parent_path(complete(file)), filename(file), p, flags); } @@ -248,7 +248,7 @@ namespace libtorrent } void set_piece_hashes(create_torrent& t, std::string const& p - , boost::function const& f, error_code& ec) + , std::function const& f, error_code& ec) { // optimized path io_service ios; diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index 4a2674b01..adf30e3ed 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -79,7 +79,7 @@ namespace libtorrent } // anonymous namespace disk_buffer_pool::disk_buffer_pool(int block_size, io_service& ios - , boost::function const& trigger_trim) + , std::function const& trigger_trim) : m_block_size(block_size) , m_in_use(0) , m_max_use(64) diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 78d02432e..40293222b 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -1479,7 +1479,7 @@ namespace libtorrent } void disk_io_thread::async_read(piece_manager* storage, peer_request const& r - , boost::function handler, void* requester + , std::function handler, void* requester , int flags) { INVARIANT_CHECK; @@ -1599,7 +1599,7 @@ namespace libtorrent void disk_io_thread::async_write(piece_manager* storage, peer_request const& r , disk_buffer_holder buffer - , boost::function handler + , std::function handler , int flags) { INVARIANT_CHECK; @@ -1709,7 +1709,7 @@ namespace libtorrent } void disk_io_thread::async_hash(piece_manager* storage, int piece, int flags - , boost::function handler, void* requester) + , std::function handler, void* requester) { #if TORRENT_USE_ASSERTS // the caller must increment the torrent refcount before @@ -1754,7 +1754,7 @@ namespace libtorrent } void disk_io_thread::async_move_storage(piece_manager* storage, std::string const& p, int flags - , boost::function handler) + , std::function handler) { #if TORRENT_USE_ASSERTS // the caller must increment the torrent refcount before @@ -1772,7 +1772,7 @@ namespace libtorrent } void disk_io_thread::async_release_files(piece_manager* storage - , boost::function handler) + , std::function handler) { disk_io_job* j = allocate_job(disk_io_job::release_files); j->storage = storage->shared_from_this(); @@ -1783,7 +1783,7 @@ namespace libtorrent void disk_io_thread::async_delete_files(piece_manager* storage , int const options - , boost::function handler) + , std::function handler) { #if TORRENT_USE_ASSERTS // the caller must increment the torrent refcount before @@ -1836,7 +1836,7 @@ namespace libtorrent void disk_io_thread::async_check_files(piece_manager* storage , add_torrent_params const* resume_data , std::vector& links - , boost::function handler) + , std::function handler) { #if TORRENT_USE_ASSERTS // the caller must increment the torrent refcount before @@ -1858,7 +1858,7 @@ namespace libtorrent } void disk_io_thread::async_rename_file(piece_manager* storage, int index, std::string const& name - , boost::function handler) + , std::function handler) { #if TORRENT_USE_ASSERTS // the caller must increment the torrent refcount before @@ -1875,7 +1875,7 @@ namespace libtorrent } void disk_io_thread::async_stop_torrent(piece_manager* storage - , boost::function handler) + , std::function handler) { // remove outstanding hash jobs belonging to this torrent std::unique_lock l2(m_job_mutex); @@ -1911,7 +1911,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE void disk_io_thread::async_cache_piece(piece_manager* storage, int piece - , boost::function handler) + , std::function handler) { #if TORRENT_USE_ASSERTS // the caller must increment the torrent refcount before @@ -1928,7 +1928,7 @@ namespace libtorrent } void disk_io_thread::async_finalize_file(piece_manager* storage, int file - , boost::function handler) + , std::function handler) { #if TORRENT_USE_ASSERTS // the caller must increment the torrent refcount before @@ -1946,7 +1946,7 @@ namespace libtorrent #endif // TORRENT_NO_DEPRECATE void disk_io_thread::async_flush_piece(piece_manager* storage, int piece - , boost::function handler) + , std::function handler) { #if TORRENT_USE_ASSERTS // the caller must increment the torrent refcount before @@ -1972,7 +1972,7 @@ namespace libtorrent void disk_io_thread::async_set_file_priority(piece_manager* storage , std::vector const& prios - , boost::function handler) + , std::function handler) { #if TORRENT_USE_ASSERTS // the caller must increment the torrent refcount before @@ -1991,7 +1991,7 @@ namespace libtorrent } void disk_io_thread::async_load_torrent(add_torrent_params* params - , boost::function handler) + , std::function handler) { disk_io_job* j = allocate_job(disk_io_job::load_torrent); j->requester = reinterpret_cast(params); @@ -2001,7 +2001,7 @@ namespace libtorrent } void disk_io_thread::async_tick_torrent(piece_manager* storage - , boost::function handler) + , std::function handler) { disk_io_job* j = allocate_job(disk_io_job::tick_storage); j->storage = storage->shared_from_this(); @@ -2028,7 +2028,7 @@ namespace libtorrent } void disk_io_thread::async_clear_piece(piece_manager* storage, int index - , boost::function handler) + , std::function handler) { #if TORRENT_USE_ASSERTS // the caller must increment the torrent refcount before diff --git a/src/file_pool.cpp b/src/file_pool.cpp index 5676521b4..b07572799 100644 --- a/src/file_pool.cpp +++ b/src/file_pool.cpp @@ -32,18 +32,14 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include "libtorrent/assert.hpp" #include "libtorrent/file_pool.hpp" #include "libtorrent/error_code.hpp" #include "libtorrent/file_storage.hpp" // for file_entry #include "libtorrent/aux_/time.hpp" +#include + namespace libtorrent { file_pool::file_pool(int size) @@ -230,7 +226,8 @@ namespace libtorrent std::unique_lock l(m_mutex); file_set::const_iterator start = m_files.lower_bound(std::make_pair(st, 0)); - file_set::const_iterator end = m_files.upper_bound(std::make_pair(st, INT_MAX)); + file_set::const_iterator end = m_files.upper_bound(std::make_pair(st + , std::numeric_limits::max())); for (file_set::const_iterator i = start; i != end; ++i) { diff --git a/src/http_connection.cpp b/src/http_connection.cpp index 183776f39..fde7bf57f 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -97,7 +97,7 @@ http_connection::http_connection(io_service& ios , m_abort(false) , m_connecting(false) { - TORRENT_ASSERT(!m_handler.empty()); + TORRENT_ASSERT(m_handler); } http_connection::~http_connection() @@ -470,7 +470,7 @@ void http_connection::close(bool force) m_hostname.clear(); m_port = 0; - m_handler.clear(); + m_handler = nullptr; m_abort = true; } diff --git a/src/kademlia/dht_tracker.cpp b/src/kademlia/dht_tracker.cpp index 730232d02..57d08d449 100644 --- a/src/kademlia/dht_tracker.cpp +++ b/src/kademlia/dht_tracker.cpp @@ -331,9 +331,9 @@ namespace libtorrent { namespace dht } void dht_tracker::get_peers(sha1_hash const& ih - , boost::function const&)> f) + , std::function const&)> f) { - boost::function > const&)> empty; + std::function > const&)> empty; m_dht.get_peers(ih, f, empty, false); #if TORRENT_USE_IPV6 m_dht6.get_peers(ih, f, empty, false); @@ -341,7 +341,7 @@ namespace libtorrent { namespace dht } void dht_tracker::announce(sha1_hash const& ih, int listen_port, int flags - , boost::function const&)> f) + , std::function const&)> f) { m_dht.announce(ih, listen_port, flags, f); #if TORRENT_USE_IPV6 @@ -364,7 +364,7 @@ namespace libtorrent { namespace dht // these functions provide a slightly higher level // interface to the get/put functionality in the DHT void get_immutable_item_callback(item const& it, boost::shared_ptr ctx - , boost::function f) + , std::function f) { // the reason to wrap here is to control the return value // since it controls whether we re-put the content @@ -384,9 +384,9 @@ namespace libtorrent { namespace dht item it; }; - bool get_mutable_item_callback(item const& it, bool authoritative + void get_mutable_item_callback(item const& it, bool authoritative , boost::shared_ptr ctx - , boost::function f) + , std::function f) { TORRENT_ASSERT(it.is_mutable()); if (authoritative) --ctx->active_traversals; @@ -398,8 +398,6 @@ namespace libtorrent { namespace dht } else if (authoritative) f(it, authoritative); - - return false; } struct put_item_ctx @@ -414,7 +412,7 @@ namespace libtorrent { namespace dht }; void put_immutable_item_callback(int responses, boost::shared_ptr ctx - , boost::function f) + , std::function f) { ctx->response_count += responses; if (--ctx->active_traversals == 0) @@ -422,7 +420,7 @@ namespace libtorrent { namespace dht } void put_mutable_item_callback(item const& it, int responses, boost::shared_ptr ctx - , boost::function cb) + , std::function cb) { ctx->response_count += responses; if (--ctx->active_traversals == 0) @@ -432,7 +430,7 @@ namespace libtorrent { namespace dht } // anonymous namespace void dht_tracker::get_item(sha1_hash const& target - , boost::function cb) + , std::function cb) { boost::shared_ptr ctx = boost::make_shared((TORRENT_USE_IPV6) ? 2 : 1); @@ -445,7 +443,7 @@ namespace libtorrent { namespace dht // key is a 32-byte binary string, the public key to look up. // the salt is optional void dht_tracker::get_item(public_key const& key - , boost::function cb + , std::function cb , std::string salt) { boost::shared_ptr @@ -457,7 +455,7 @@ namespace libtorrent { namespace dht } void dht_tracker::put_item(entry const& data - , boost::function cb) + , std::function cb) { std::string flat_data; bencode(std::back_inserter(flat_data), data); @@ -474,8 +472,8 @@ namespace libtorrent { namespace dht } void dht_tracker::put_item(public_key const& key - , boost::function cb - , boost::function data_cb, std::string salt) + , std::function cb + , std::function data_cb, std::string salt) { boost::shared_ptr ctx = boost::make_shared((TORRENT_USE_IPV6) ? 2 : 1); @@ -489,7 +487,7 @@ namespace libtorrent { namespace dht } void dht_tracker::direct_request(udp::endpoint ep, entry& e - , boost::function f) + , std::function f) { #if TORRENT_USE_IPV6 if (ep.protocol() == udp::v6()) diff --git a/src/kademlia/get_peers.cpp b/src/kademlia/get_peers.cpp index cbd58b224..4d748e674 100644 --- a/src/kademlia/get_peers.cpp +++ b/src/kademlia/get_peers.cpp @@ -278,8 +278,8 @@ void obfuscated_get_peers::done() // don't call these when the obfuscated_get_peers // is done, we're passing them on to be called when // ta completes. - m_data_callback.clear(); - m_nodes_callback.clear(); + m_data_callback = nullptr; + m_nodes_callback = nullptr; #ifndef TORRENT_DISABLE_LOGGING get_node().observer()->log(dht_logger::traversal, "[%p] obfuscated get_peers " diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index 4e0d879df..293757380 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -424,8 +424,8 @@ void node::add_node(udp::endpoint node) } void node::get_peers(sha1_hash const& info_hash - , boost::function const&)> dcallback - , boost::function > const&)> ncallback + , std::function const&)> dcallback + , std::function > const&)> ncallback , bool noseeds) { // search for nodes with ids close to id or with peers @@ -445,7 +445,7 @@ void node::get_peers(sha1_hash const& info_hash } void node::announce(sha1_hash const& info_hash, int listen_port, int flags - , boost::function const&)> f) + , std::function const&)> f) { #ifndef TORRENT_DISABLE_LOGGING if (m_observer) @@ -463,7 +463,7 @@ void node::announce(sha1_hash const& info_hash, int listen_port, int flags } void node::direct_request(udp::endpoint ep, entry& e - , boost::function f) + , std::function f) { // not really a traversal boost::intrusive_ptr algo( @@ -479,7 +479,7 @@ void node::direct_request(udp::endpoint ep, entry& e } void node::get_item(sha1_hash const& target - , boost::function f) + , std::function f) { #ifndef TORRENT_DISABLE_LOGGING if (m_observer) @@ -497,7 +497,7 @@ void node::get_item(sha1_hash const& target } void node::get_item(public_key const& pk, std::string const& salt - , boost::function f) + , std::function f) { #ifndef TORRENT_DISABLE_LOGGING if (m_observer) @@ -524,7 +524,7 @@ void put(std::vector > const& nodes void put_data_cb(item i, bool auth , boost::intrusive_ptr ta - , boost::function f) + , std::function f) { // call data_callback only when we got authoritative data. if (auth) @@ -536,7 +536,7 @@ void put_data_cb(item i, bool auth } // namespace -void node::put_item(sha1_hash const& target, entry const& data, boost::function f) +void node::put_item(sha1_hash const& target, entry const& data, std::function f) { #ifndef TORRENT_DISABLE_LOGGING if (m_observer) @@ -561,8 +561,8 @@ void node::put_item(sha1_hash const& target, entry const& data, boost::function< } void node::put_item(public_key const& pk, std::string const& salt - , boost::function f - , boost::function data_cb) + , std::function f + , std::function data_cb) { #ifndef TORRENT_DISABLE_LOGGING if (m_observer) diff --git a/src/lsd.cpp b/src/lsd.cpp index c730b27d9..6f37013a0 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -307,7 +307,7 @@ void lsd::close() #if TORRENT_USE_IPV6 m_disabled6 = true; #endif - m_callback.clear(); + m_callback = nullptr; } } // libtorrent namespace diff --git a/src/session.cpp b/src/session.cpp index 10a069d58..9e3ac34b5 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -300,7 +300,7 @@ namespace libtorrent ios = m_io_service.get(); } - m_impl = boost::make_shared(boost::ref(*ios)); + m_impl = boost::make_shared(std::ref(*ios)); *static_cast(this) = session_handle(m_impl.get()); #ifndef TORRENT_DISABLE_EXTENSIONS diff --git a/src/session_handle.cpp b/src/session_handle.cpp index 5a786ed9e..041526028 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -106,7 +106,7 @@ namespace libtorrent } void session_handle::get_torrent_status(std::vector* ret - , boost::function const& pred + , std::function const& pred , std::uint32_t flags) const { auto predr = std::ref(pred); @@ -536,7 +536,7 @@ namespace libtorrent } void session_handle::dht_put_item(std::array key - , boost::function& + , std::function& , std::uint64_t&, std::string const&)> cb , std::string salt) { @@ -601,7 +601,7 @@ namespace libtorrent } #endif // TORRENT_NO_DEPRECATE - void session_handle::add_extension(boost::function(torrent_handle const&, void*)> ext) + void session_handle::add_extension(std::function(torrent_handle const&, void*)> ext) { #ifndef TORRENT_DISABLE_EXTENSIONS async_call(&session_impl::add_extension, ext); @@ -1020,7 +1020,7 @@ namespace libtorrent return m_impl->wait_for_alert(max_wait); } - void session_handle::set_alert_notify(boost::function const& fun) + void session_handle::set_alert_notify(std::function const& fun) { m_impl->alerts().set_notify_function(fun); } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 82c609ac9..52a4a63a2 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -774,7 +774,7 @@ namespace aux { void session_impl::add_extension(ext_function_t ext) { TORRENT_ASSERT(is_single_thread()); - TORRENT_ASSERT_VAL(ext, ext); + TORRENT_ASSERT(ext); add_ses_extension(boost::make_shared( session_plugin_wrapper(ext))); @@ -1536,7 +1536,7 @@ namespace aux { // separate function. At least most of it if (!m_settings.get_bool(settings_pack::force_proxy)) { - ret.sock = boost::make_shared(boost::ref(m_io_service)); + ret.sock = boost::make_shared(std::ref(m_io_service)); ret.sock->open(bind_ep.protocol(), ec); last_op = listen_failed_alert::open; if (ec) @@ -1719,7 +1719,7 @@ namespace aux { } } // force-proxy mode - ret.udp_sock = boost::make_shared(boost::ref(m_io_service)); + ret.udp_sock = boost::make_shared(std::ref(m_io_service)); #if TORRENT_HAS_BINDTODEVICE if (!device.empty()) { @@ -2015,7 +2015,7 @@ namespace aux { if (m_socks_listen_socket) return; - m_socks_listen_socket = boost::make_shared(boost::ref(m_io_service)); + m_socks_listen_socket = boost::make_shared(std::ref(m_io_service)); bool const ret = instantiate_connection(m_io_service, proxy() , *m_socks_listen_socket, nullptr, nullptr, false, false); TORRENT_ASSERT_VAL(ret, ret); @@ -4457,7 +4457,7 @@ namespace aux { #endif void session_impl::get_torrent_status(std::vector* ret - , boost::function const& pred + , std::function const& pred , std::uint32_t flags) const { for (torrent_map::const_iterator i @@ -4783,7 +4783,7 @@ namespace aux { if (string_begins_no_case("file://", params.url.c_str()) && !params.ti) { std::string const filename = resolve_file_url(params.url); - boost::shared_ptr t = boost::make_shared(filename, boost::ref(ec), 0); + boost::shared_ptr t = boost::make_shared(filename, std::ref(ec), 0); if (ec) return std::make_pair(ptr_t(), false); params.url.clear(); params.ti = t; @@ -4879,7 +4879,7 @@ namespace aux { int queue_pos = ++m_max_queue_pos; - torrent_ptr = boost::make_shared(boost::ref(*this) + torrent_ptr = boost::make_shared(std::ref(*this) , 16 * 1024, queue_pos, m_paused , boost::cref(params), boost::cref(params.info_hash)); @@ -5555,10 +5555,10 @@ namespace aux { m_dht_storage = m_dht_storage_constructor(m_dht_settings); m_dht = boost::make_shared( static_cast(this) - , boost::ref(m_io_service) + , std::ref(m_io_service) , std::bind(&session_impl::send_udp_packet, this, false, _1, _2, _3, _4) , boost::cref(m_dht_settings) - , boost::ref(m_stats_counters) + , std::ref(m_stats_counters) , *m_dht_storage , startup_state); @@ -5575,7 +5575,7 @@ namespace aux { } m_dht_nodes.clear(); - m_dht->start(startup_state, std::bind(&on_bootstrap, boost::ref(m_alerts))); + m_dht->start(startup_state, std::bind(&on_bootstrap, std::ref(m_alerts))); } void session_impl::stop_dht() @@ -5739,7 +5739,7 @@ namespace aux { } void put_mutable_callback(dht::item& i - , boost::function& + , std::function& , std::uint64_t&, std::string const&)> cb) { entry value = i.value(); @@ -5770,37 +5770,37 @@ namespace aux { void session_impl::dht_put_immutable_item(entry const& data, sha1_hash target) { if (!m_dht) return; - m_dht->put_item(data, std::bind(&on_dht_put_immutable_item, boost::ref(m_alerts) + m_dht->put_item(data, std::bind(&on_dht_put_immutable_item, std::ref(m_alerts) , target, _1)); } void session_impl::dht_put_mutable_item(std::array key - , boost::function& + , std::function& , std::uint64_t&, std::string const&)> cb , std::string salt) { if (!m_dht) return; m_dht->put_item(dht::public_key(key.data()) - , std::bind(&on_dht_put_mutable_item, boost::ref(m_alerts), _1, _2) + , std::bind(&on_dht_put_mutable_item, std::ref(m_alerts), _1, _2) , std::bind(&put_mutable_callback, _1, cb), salt); } void session_impl::dht_get_peers(sha1_hash const& info_hash) { if (!m_dht) return; - m_dht->get_peers(info_hash, std::bind(&on_dht_get_peers, boost::ref(m_alerts), info_hash, _1)); + m_dht->get_peers(info_hash, std::bind(&on_dht_get_peers, std::ref(m_alerts), info_hash, _1)); } void session_impl::dht_announce(sha1_hash const& info_hash, int port, int flags) { if (!m_dht) return; - m_dht->announce(info_hash, port, flags, std::bind(&on_dht_get_peers, boost::ref(m_alerts), info_hash, _1)); + m_dht->announce(info_hash, port, flags, std::bind(&on_dht_get_peers, std::ref(m_alerts), info_hash, _1)); } void session_impl::dht_direct_request(udp::endpoint ep, entry& e, void* userdata) { if (!m_dht) return; - m_dht->direct_request(ep, e, std::bind(&on_direct_response, boost::ref(m_alerts), userdata, _1)); + m_dht->direct_request(ep, e, std::bind(&on_direct_response, std::ref(m_alerts), userdata, _1)); } #endif @@ -6422,7 +6422,7 @@ namespace aux { if (m_lsd) return; - m_lsd = boost::make_shared(boost::ref(m_io_service) + m_lsd = boost::make_shared(std::ref(m_io_service) , std::bind(&session_impl::on_lsd_peer, this, _1, _2) #ifndef TORRENT_DISABLE_LOGGING , std::bind(&session_impl::on_lsd_log, this, _1) @@ -6450,7 +6450,7 @@ namespace aux { // the natpmp constructor may fail and call the callbacks // into the session_impl. - m_natpmp = boost::make_shared(boost::ref(m_io_service) + m_natpmp = boost::make_shared(std::ref(m_io_service) , std::bind(&session_impl::on_port_mapping , this, _1, _2, _3, _4, _5, 0) , std::bind(&session_impl::on_port_map_log @@ -6472,7 +6472,7 @@ namespace aux { if (m_upnp) return m_upnp.get(); // the upnp constructor may fail and call the callbacks - m_upnp = boost::make_shared(boost::ref(m_io_service) + m_upnp = boost::make_shared(std::ref(m_io_service) , m_settings.get_str(settings_pack::user_agent) , std::bind(&session_impl::on_port_mapping , this, _1, _2, _3, _4, _5, 1) diff --git a/src/torrent.cpp b/src/torrent.cpp index 665834ea0..92e51c458 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -466,7 +466,7 @@ namespace libtorrent } error_code e; - boost::shared_ptr tf(boost::make_shared(data, size, boost::ref(e), 0)); + boost::shared_ptr tf(boost::make_shared(data, size, std::ref(e), 0)); if (e) { set_error(e, torrent_status::error_file_url); @@ -1461,7 +1461,7 @@ namespace libtorrent m_extensions.erase(i); } - void torrent::add_extension_fun(boost::function(torrent_handle const&, void*)> const& ext + void torrent::add_extension_fun(std::function(torrent_handle const&, void*)> const& ext , void* userdata) { boost::shared_ptr tp(ext(get_handle(), userdata)); @@ -1598,7 +1598,7 @@ namespace libtorrent // create the SSL context for this torrent. We need to // inject the root certificate, and no other, to // verify other peers against - boost::shared_ptr ctx = boost::make_shared(boost::ref(m_ses.get_io_service()), context::sslv23); + boost::shared_ptr ctx = boost::make_shared(std::ref(m_ses.get_io_service()), context::sslv23); if (!ctx) { @@ -2417,7 +2417,7 @@ namespace libtorrent leave_seed_mode(true); m_ses.disk_thread().async_release_files(m_storage.get() - , boost::function()); + , std::function()); // forget that we have any pieces m_have_all = false; @@ -6167,7 +6167,7 @@ namespace libtorrent if (m_ses.is_aborted()) return; boost::shared_ptr s - = boost::make_shared(boost::ref(m_ses.get_io_service())); + = boost::make_shared(std::ref(m_ses.get_io_service())); if (!s) return; void* userdata = nullptr; @@ -6250,12 +6250,12 @@ namespace libtorrent if (web->type == web_seed_entry::url_seed) { c = boost::make_shared( - boost::cref(pack), boost::ref(*web)); + boost::cref(pack), std::ref(*web)); } else if (web->type == web_seed_entry::http_seed) { c = boost::make_shared( - boost::cref(pack), boost::ref(*web)); + boost::cref(pack), std::ref(*web)); } if (!c) return; diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index c44fb53df..d7ab77960 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -206,7 +206,7 @@ namespace libtorrent } void torrent_handle::add_extension( - boost::function(torrent_handle const&, void*)> const& ext + std::function(torrent_handle const&, void*)> const& ext , void* userdata) { #ifndef TORRENT_DISABLE_EXTENSIONS diff --git a/src/tracker_manager.cpp b/src/tracker_manager.cpp index bddef9eb9..6ef90a624 100644 --- a/src/tracker_manager.cpp +++ b/src/tracker_manager.cpp @@ -289,7 +289,7 @@ namespace libtorrent { boost::shared_ptr con = boost::make_shared( - boost::ref(ios), boost::ref(*this), boost::cref(req), c); + std::ref(ios), std::ref(*this), boost::cref(req), c); m_http_conns.push_back(con); con->start(); return; @@ -298,7 +298,7 @@ namespace libtorrent { boost::shared_ptr con = boost::make_shared( - boost::ref(ios), boost::ref(*this), boost::cref(req) , c); + std::ref(ios), std::ref(*this), boost::cref(req) , c); m_udp_conns[con->transaction_id()] = con; con->start(); return; diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index 273946342..54933b0a8 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -478,7 +478,7 @@ void udp_socket::set_proxy_settings(aux::proxy_settings const& ps) { // connect to socks5 server and open up the UDP tunnel - m_socks5_connection = boost::make_shared(boost::ref(m_socket.get_io_service())); + m_socks5_connection = boost::make_shared(std::ref(m_socket.get_io_service())); m_socks5_connection->start(ps); } } diff --git a/src/upnp.cpp b/src/upnp.cpp index 47e7afe4f..52f32c37a 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -313,7 +313,7 @@ void upnp::resend_request(error_code const& ec) d.upnp_connection.reset(new http_connection(m_io_service , m_resolver , std::bind(&upnp::on_upnp_xml, self(), _1, _2 - , boost::ref(d), _5))); + , std::ref(d), _5))); d.upnp_connection->get(d.url, seconds(30), 1); } TORRENT_CATCH (std::exception& exc) @@ -774,8 +774,8 @@ void upnp::update_map(rootdevice& d, int i) d.upnp_connection.reset(new http_connection(m_io_service , m_resolver , std::bind(&upnp::on_upnp_map_response, self(), _1, _2 - , boost::ref(d), i, _5), true, default_max_bottled_buffer_size - , std::bind(&upnp::create_port_mapping, self(), _1, boost::ref(d), i))); + , std::ref(d), i, _5), true, default_max_bottled_buffer_size + , std::bind(&upnp::create_port_mapping, self(), _1, std::ref(d), i))); d.upnp_connection->start(d.hostname, d.port , seconds(10), 1); @@ -786,8 +786,8 @@ void upnp::update_map(rootdevice& d, int i) d.upnp_connection.reset(new http_connection(m_io_service , m_resolver , std::bind(&upnp::on_upnp_unmap_response, self(), _1, _2 - , boost::ref(d), i, _5), true, default_max_bottled_buffer_size - , std::bind(&upnp::delete_port_mapping, self(), boost::ref(d), i))); + , std::ref(d), i, _5), true, default_max_bottled_buffer_size + , std::bind(&upnp::delete_port_mapping, self(), std::ref(d), i))); d.upnp_connection->start(d.hostname, d.port , seconds(10), 1); } @@ -940,7 +940,7 @@ void upnp::on_upnp_xml(error_code const& e } parse_state s; - xml_parse(p.get_body(), std::bind(&find_control_url, _1, _2, _3, boost::ref(s))); + xml_parse(p.get_body(), std::bind(&find_control_url, _1, _2, _3, std::ref(s))); if (s.control_url.empty()) { #ifndef TORRENT_DISABLE_LOGGING @@ -1004,8 +1004,8 @@ void upnp::on_upnp_xml(error_code const& e d.upnp_connection.reset(new http_connection(m_io_service , m_resolver , std::bind(&upnp::on_upnp_get_ip_address_response, self(), _1, _2 - , boost::ref(d), _5), true, default_max_bottled_buffer_size - , std::bind(&upnp::get_ip_address, self(), boost::ref(d)))); + , std::ref(d), _5), true, default_max_bottled_buffer_size + , std::bind(&upnp::get_ip_address, self(), std::ref(d)))); d.upnp_connection->start(d.hostname, d.port , seconds(10), 1); } @@ -1237,7 +1237,7 @@ void upnp::on_upnp_get_ip_address_response(error_code const& e #endif ip_address_parse_state s; - xml_parse(body, std::bind(&find_ip_address, _1, _2, boost::ref(s))); + xml_parse(body, std::bind(&find_ip_address, _1, _2, std::ref(s))); #ifndef TORRENT_DISABLE_LOGGING if (s.error_code != -1) { @@ -1335,7 +1335,7 @@ void upnp::on_upnp_map_response(error_code const& e error_code_parse_state s; span body = p.get_body(); - xml_parse(body, std::bind(&find_error_code, _1, _2, boost::ref(s))); + xml_parse(body, std::bind(&find_error_code, _1, _2, std::ref(s))); if (s.error_code != -1) { @@ -1475,7 +1475,7 @@ void upnp::on_upnp_unmap_response(error_code const& e error_code_parse_state s; if (p.header_finished()) { - xml_parse(p.get_body(), std::bind(&find_error_code, _1, _2, boost::ref(s))); + xml_parse(p.get_body(), std::bind(&find_error_code, _1, _2, std::ref(s))); } int const proto = m_mappings[mapping].protocol; diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index 3b01d2520..88dbdc50d 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -938,16 +938,13 @@ void utp_stream::on_read(void* self, size_t bytes_transferred TORRENT_ASSERT(s->m_read_handler); TORRENT_ASSERT(bytes_transferred > 0 || ec || s->m_impl->m_null_buffers); s->m_io_service.post(std::bind(s->m_read_handler, ec, bytes_transferred)); - s->m_read_handler.clear(); -// boost::function2 tmp; -// tmp.swap(s->m_read_handler); + s->m_read_handler = nullptr; if (kill && s->m_impl) { TORRENT_ASSERT(ec); detach_utp_impl(s->m_impl); s->m_impl = nullptr; } -// tmp(ec, bytes_transferred); } void utp_stream::on_write(void* self, size_t bytes_transferred @@ -962,16 +959,13 @@ void utp_stream::on_write(void* self, size_t bytes_transferred TORRENT_ASSERT(s->m_write_handler); TORRENT_ASSERT(bytes_transferred > 0 || ec); s->m_io_service.post(std::bind(s->m_write_handler, ec, bytes_transferred)); - s->m_write_handler.clear(); -// boost::function2 tmp; -// tmp.swap(s->m_read_handler); + s->m_write_handler = nullptr; if (kill && s->m_impl) { TORRENT_ASSERT(ec); detach_utp_impl(s->m_impl); s->m_impl = nullptr; } -// tmp(ec, bytes_transferred); } void utp_stream::on_connect(void* self, error_code const& ec, bool kill) @@ -984,16 +978,13 @@ void utp_stream::on_connect(void* self, error_code const& ec, bool kill) TORRENT_ASSERT(s->m_connect_handler); s->m_io_service.post(std::bind(s->m_connect_handler, ec)); - s->m_connect_handler.clear(); -// boost::function1 tmp; -// s->m_connect_handler.swap(tmp); + s->m_connect_handler = nullptr; if (kill && s->m_impl) { TORRENT_ASSERT(ec); detach_utp_impl(s->m_impl); s->m_impl = nullptr; } -// tmp(ec); } void utp_stream::add_read_buffer(void* buf, size_t len) diff --git a/src/xml_parse.cpp b/src/xml_parse.cpp index 3bbdbce9d..c54dc72cb 100644 --- a/src/xml_parse.cpp +++ b/src/xml_parse.cpp @@ -39,7 +39,7 @@ namespace libtorrent { TORRENT_EXTRA_EXPORT void xml_parse(span input - , boost::function callback) + , std::function callback) { char const* p = input.data(); char const* end = input.data() + input.size(); diff --git a/test/bittorrent_peer.cpp b/test/bittorrent_peer.cpp index a1178dd53..16b0491f3 100644 --- a/test/bittorrent_peer.cpp +++ b/test/bittorrent_peer.cpp @@ -47,7 +47,7 @@ using namespace libtorrent; using namespace std::placeholders; peer_conn::peer_conn(io_service& ios - , boost::function on_msg + , std::function on_msg , torrent_info const& ti , tcp::endpoint const& ep , peer_mode_t mode) diff --git a/test/bittorrent_peer.hpp b/test/bittorrent_peer.hpp index e93c09744..be9bab32c 100644 --- a/test/bittorrent_peer.hpp +++ b/test/bittorrent_peer.hpp @@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/address.hpp" #include "libtorrent/torrent_info.hpp" #include "test.hpp" // for EXPORT -#include +#include using namespace libtorrent; @@ -50,7 +50,7 @@ struct EXPORT peer_conn { uploader, downloader, idle }; peer_conn(io_service& ios - , boost::function on_msg + , std::function on_msg , libtorrent::torrent_info const& ti , libtorrent::tcp::endpoint const& ep , peer_mode_t mode); @@ -86,7 +86,7 @@ private: int read_pos; - boost::function m_on_msg; + std::function m_on_msg; enum state_t { diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 611af2e9d..9ddeff446 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -758,7 +758,7 @@ boost::shared_ptr create_torrent(std::ostream* file bencode(out, tor); error_code ec; return boost::make_shared( - &tmp[0], tmp.size(), boost::ref(ec), 0); + &tmp[0], tmp.size(), std::ref(ec), 0); } std::tuple diff --git a/test/test_alert_manager.cpp b/test/test_alert_manager.cpp index 0c9f8b023..a4c54e33a 100644 --- a/test/test_alert_manager.cpp +++ b/test/test_alert_manager.cpp @@ -124,7 +124,7 @@ TORRENT_TEST(notify_function) // if there are queued alerts when we set the notify function, // that counts as an edge and it's called - mgr.set_notify_function(std::bind(&test_notify_fun, boost::ref(cnt))); + mgr.set_notify_function(std::bind(&test_notify_fun, std::ref(cnt))); TEST_EQUAL(mgr.pending(), true); TEST_EQUAL(cnt, 1); diff --git a/test/test_bandwidth_limiter.cpp b/test/test_bandwidth_limiter.cpp index 5845f3bd7..764e47c40 100644 --- a/test/test_bandwidth_limiter.cpp +++ b/test/test_bandwidth_limiter.cpp @@ -41,9 +41,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/time.hpp" #include "libtorrent/aux_/session_settings.hpp" -#include +#include "libtorrent/aux_/disable_warnings_push.hpp" #include #include +#include "libtorrent/aux_/disable_warnings_pop.hpp" #include #include @@ -153,7 +154,7 @@ static void nop() {} void run_test(connections_t& v , bandwidth_manager& manager - , boost::function f = &nop) + , std::function f = &nop) { std::cerr << "-------------" << std::endl; @@ -235,7 +236,7 @@ void test_connections_variable_rate(int num, int limit, int torrent_limit) , std::bind(&peer_connection::throttle, _1, limit)); run_test(v, manager, std::bind(&do_change_peer_rate - , boost::ref(v), limit)); + , std::ref(v), limit)); if (torrent_limit > 0 && limit * num > torrent_limit) limit = torrent_limit / num; @@ -359,7 +360,7 @@ void test_torrents_variable_rate(int num, int limit, int global_limit) std::copy(v1.begin(), v1.end(), std::back_inserter(v)); std::copy(v2.begin(), v2.end(), std::back_inserter(v)); - run_test(v, manager, std::bind(&do_change_rate, boost::ref(t1), boost::ref(t2), limit)); + run_test(v, manager, std::bind(&do_change_rate, std::ref(t1), std::ref(t2), limit)); if (global_limit > 0 && global_limit < 2 * limit) limit = global_limit / 2; diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index 9c0a26c51..2ae38b83c 100644 --- a/test/test_fast_extension.cpp +++ b/test/test_fast_extension.cpp @@ -491,7 +491,7 @@ TORRENT_TEST(reject_fast) allowed_fast.push_back(3); std::for_each(allowed_fast.begin(), allowed_fast.end() - , std::bind(&send_allow_fast, boost::ref(s), _1)); + , std::bind(&send_allow_fast, std::ref(s), _1)); print_session_log(*ses); while (!allowed_fast.empty()) @@ -600,7 +600,7 @@ TORRENT_TEST(reject_suggest) suggested.push_back(3); std::for_each(suggested.begin(), suggested.end() - , std::bind(&send_suggest_piece, boost::ref(s), _1)); + , std::bind(&send_suggest_piece, std::ref(s), _1)); print_session_log(*ses); send_unchoke(s); @@ -679,7 +679,7 @@ TORRENT_TEST(suggest_order) suggested.push_back(3); std::for_each(suggested.begin(), suggested.end() - , std::bind(&send_suggest_piece, boost::ref(s), _1)); + , std::bind(&send_suggest_piece, std::ref(s), _1)); print_session_log(*ses); send_unchoke(s); diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 70fd332fa..f13e1b00b 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -139,7 +139,7 @@ boost::shared_ptr setup_torrent(file_storage& fs error_code ec; boost::shared_ptr info(boost::make_shared(&buf[0] - , buf.size(), boost::ref(ec), 0)); + , buf.size(), std::ref(ec), 0)); if (ec) { @@ -447,7 +447,7 @@ void test_check_files(std::string const& test_path std::vector buf; bencode(std::back_inserter(buf), t.generate()); - info = boost::make_shared(&buf[0], buf.size(), boost::ref(ec), 0); + info = boost::make_shared(&buf[0], buf.size(), std::ref(ec), 0); aux::session_settings set; file_pool fp; @@ -523,7 +523,7 @@ void run_test(bool unbuffered) std::vector buf; bencode(std::back_inserter(buf), t.generate()); - info = boost::make_shared(&buf[0], buf.size(), boost::ref(ec), 0); + info = boost::make_shared(&buf[0], buf.size(), std::ref(ec), 0); std::cerr << "=== test 1 === " << (unbuffered?"unbuffered":"buffered") << std::endl; // run_storage_tests writes piece 0, 1 and 2. not 3 @@ -567,7 +567,7 @@ void run_test(bool unbuffered) std::vector buf; bencode(std::back_inserter(buf), t.generate()); - info = boost::make_shared(&buf[0], buf.size(), boost::ref(ec), 0); + info = boost::make_shared(&buf[0], buf.size(), std::ref(ec), 0); std::cerr << "=== test 3 ===" << std::endl; diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index 304ddee46..e4969e505 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -171,7 +171,7 @@ TORRENT_TEST(long_names) std::vector buf; bencode(std::back_inserter(buf), torrent); error_code ec; - boost::shared_ptr ti(boost::make_shared(&buf[0], buf.size(), boost::ref(ec))); + boost::shared_ptr ti(boost::make_shared(&buf[0], buf.size(), std::ref(ec))); TEST_CHECK(!ec); } @@ -189,7 +189,7 @@ TORRENT_TEST(total_wanted) bencode(std::back_inserter(tmp), t.generate()); error_code ec; boost::shared_ptr info(boost::make_shared( - &tmp[0], tmp.size(), boost::ref(ec))); + &tmp[0], tmp.size(), std::ref(ec))); settings_pack pack; pack.set_int(settings_pack::alert_mask, alert::storage_notification); @@ -227,7 +227,7 @@ TORRENT_TEST(added_peers) bencode(std::back_inserter(tmp), t.generate()); error_code ec; boost::shared_ptr info(boost::make_shared( - &tmp[0], tmp.size(), boost::ref(ec))); + &tmp[0], tmp.size(), std::ref(ec))); settings_pack pack; pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48130"); @@ -275,7 +275,7 @@ TORRENT_TEST(torrent) std::back_insert_iterator > out(tmp); bencode(out, t.generate()); error_code ec; - boost::shared_ptr info(boost::make_shared(&tmp[0], tmp.size(), boost::ref(ec), 0)); + boost::shared_ptr info(boost::make_shared(&tmp[0], tmp.size(), std::ref(ec), 0)); TEST_CHECK(info->num_pieces() > 0); test_running_torrent(info, file_size); @@ -302,7 +302,7 @@ TORRENT_TEST(torrent) std::back_insert_iterator > out(tmp); bencode(out, t.generate()); error_code ec; - boost::shared_ptr info(boost::make_shared(&tmp[0], tmp.size(), boost::ref(ec), 0)); + boost::shared_ptr info(boost::make_shared(&tmp[0], tmp.size(), std::ref(ec), 0)); test_running_torrent(info, 1024); } } @@ -351,7 +351,7 @@ TORRENT_TEST(duplicate_is_not_error) plugin_creator creator(called); add_torrent_params p; - p.ti = boost::make_shared(&tmp[0], tmp.size(), boost::ref(ec), 0); + p.ti = boost::make_shared(&tmp[0], tmp.size(), std::ref(ec), 0); p.flags &= ~add_torrent_params::flag_paused; p.flags &= ~add_torrent_params::flag_auto_managed; p.flags &= ~add_torrent_params::flag_duplicate_is_error; @@ -405,7 +405,7 @@ TORRENT_TEST(rename_file) std::back_insert_iterator > out(tmp); bencode(out, t.generate()); error_code ec; - boost::shared_ptr info(boost::make_shared(&tmp[0], tmp.size(), boost::ref(ec), 0)); + boost::shared_ptr info(boost::make_shared(&tmp[0], tmp.size(), std::ref(ec), 0)); TEST_EQUAL(info->files().file_path(0), combine_path("test3","tmp1")); diff --git a/test/test_upnp.cpp b/test/test_upnp.cpp index 0ed8a6bae..91b7202e5 100644 --- a/test/test_upnp.cpp +++ b/test/test_upnp.cpp @@ -161,7 +161,7 @@ void run_upnp_test(char const* root_filename, char const* router_model, char con std::string user_agent = "test agent"; - boost::shared_ptr upnp_handler(new upnp(boost::ref(ios) + boost::shared_ptr upnp_handler(new upnp(std::ref(ios) , user_agent, &callback, &log_callback, false)); upnp_handler->start(); upnp_handler->discover_device(); diff --git a/test/test_xml.cpp b/test/test_xml.cpp index 75ff69807..7ecee9279 100644 --- a/test/test_xml.cpp +++ b/test/test_xml.cpp @@ -273,7 +273,7 @@ void test_parse(char const* in, char const* expected) { std::string out; xml_parse(str(in), std::bind(&parser_callback - , boost::ref(out), _1, _2, _3, _4, _5)); + , std::ref(out), _1, _2, _3, _4, _5)); std::fprintf(stderr, "in: %s\n out: %s\nexpected: %s\n" , in, out.c_str(), expected); TEST_EQUAL(out, expected); @@ -282,7 +282,7 @@ void test_parse(char const* in, char const* expected) TORRENT_TEST(upnp_parser1) { parse_state xml_s; - xml_parse(upnp_xml, std::bind(&find_control_url, _1, _2, _3, boost::ref(xml_s))); + xml_parse(upnp_xml, std::bind(&find_control_url, _1, _2, _3, std::ref(xml_s))); std::cerr << "namespace " << xml_s.service_type << std::endl; std::cerr << "url_base: " << xml_s.url_base << std::endl; @@ -296,7 +296,7 @@ TORRENT_TEST(upnp_parser1) TORRENT_TEST(upnp_parser2) { parse_state xml_s; - xml_parse(upnp_xml2, std::bind(&find_control_url, _1, _2, _3, boost::ref(xml_s))); + xml_parse(upnp_xml2, std::bind(&find_control_url, _1, _2, _3, std::ref(xml_s))); std::cerr << "namespace " << xml_s.service_type << std::endl; std::cerr << "url_base: " << xml_s.url_base << std::endl;