replace boost::function with std::function

This commit is contained in:
arvidn 2016-08-12 21:31:55 -04:00
parent 5308de69fe
commit 8c8c3d5587
70 changed files with 283 additions and 311 deletions

View File

@ -70,7 +70,7 @@ int main(int argc, char* argv[])
}
add_torrent_params p;
p.save_path = "./";
p.ti = boost::make_shared<torrent_info>(std::string(argv[1]), boost::ref(ec), 0);
p.ti = boost::make_shared<torrent_info>(std::string(argv[1]), std::ref(ec), 0);
if (ec)
{
std::fprintf(stderr, "%s\n", ec.message().c_str());

View File

@ -36,10 +36,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include <string>
#include <vector>
#include <map>
#include <functional>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#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<boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)>>
std::vector<std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)>>
extensions;
// the default tracker id to be used when announcing to trackers. By

View File

@ -40,15 +40,16 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/config.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <functional>
#include <list>
#include <utility> // for std::forward
#include <mutex>
#include <condition_variable>
#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<void()> const& fun);
void set_notify_function(std::function<void()> const& fun);
#ifndef TORRENT_DISABLE_EXTENSIONS
void add_extension(boost::shared_ptr<plugin> 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<void()> m_notify;
std::function<void()> 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

View File

@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/aux_/session_impl.hpp"
#include <boost/function.hpp>
#include <functional>
namespace libtorrent { namespace aux {

View File

@ -112,7 +112,7 @@ namespace libtorrent
struct bencode_map_entry;
typedef boost::function<bool(udp::endpoint const& source
typedef std::function<bool(udp::endpoint const& source
, bdecode_node const& request, entry& response)> dht_extension_handler_t;
struct listen_socket_t
@ -217,7 +217,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_EXTENSIONS
using ext_function_t
= boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)>;
= std::function<boost::shared_ptr<torrent_plugin>(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<boost::shared_ptr<torrent_plugin>(
void add_extension(std::function<boost::shared_ptr<torrent_plugin>(
torrent_handle const&, void*)> ext);
void add_ses_extension(boost::shared_ptr<plugin> 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<char, 32> key
, boost::function<void(entry&, std::array<char,64>&
, std::function<void(entry&, std::array<char,64>&
, 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<torrent> tptr, int options) override;
void get_torrent_status(std::vector<torrent_status>* ret
, boost::function<bool(torrent_status const&)> const& pred
, std::function<bool(torrent_status const&)> const& pred
, std::uint32_t flags) const;
void refresh_torrent_status(std::vector<torrent_status>* ret
, std::uint32_t flags) const;

View File

@ -39,6 +39,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/io_service.hpp"
#include "libtorrent/disk_buffer_holder.hpp"
#include <functional>
#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 <boost/weak_ptr.hpp>
#include <boost/function.hpp>
#ifndef TORRENT_DISABLE_LOGGING
#include <boost/shared_ptr.hpp>
@ -155,7 +156,7 @@ namespace libtorrent { namespace aux
virtual io_service& get_io_service() = 0;
virtual resolver_interface& get_resolver() = 0;
typedef boost::function<void(error_code const&, std::vector<address> const&)>
typedef std::function<void(error_code const&, std::vector<address> const&)>
callback_t;
// TODO: 2 remove this. There's already get_resolver()

View File

@ -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<void()> const& trigger_trim);
, std::function<void()> const& trigger_trim);
private:

View File

@ -61,7 +61,7 @@ namespace libtorrent
// determines if the operating system supports IPv6
TORRENT_EXTRA_EXPORT bool supports_ipv6();
typedef boost::function<void(udp::endpoint const& from
typedef std::function<void(udp::endpoint const& from
, char* buffer, int size)> receive_handler_t;
class TORRENT_EXTRA_EXPORT broadcast_socket

View File

@ -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<bool(std::string)> p, std::uint32_t flags = 0);
, std::function<bool(std::string)> 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<void(int)> const& f, error_code& ec);
, std::function<void(int)> 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<bool(std::string)> p, std::uint32_t flags = 0);
, std::function<bool(std::string)> 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<void(int)> f, error_code& ec);
, std::function<void(int)> f, error_code& ec);
TORRENT_EXPORT void set_piece_hashes_deprecated(create_torrent& t
, std::wstring const& p
, boost::function<void(int)> f, error_code& ec);
, std::function<void(int)> f, error_code& ec);
#ifndef BOOST_NO_EXCEPTIONS
template <class Fun>

View File

@ -36,11 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <vector>
#include <mutex>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/utility.hpp>
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
@ -48,11 +44,14 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/pool/pool.hpp>
#endif
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#if TORRENT_USE_INVARIANT_CHECKS
#include <set>
#endif
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <vector>
#include <mutex>
#include <functional>
#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<void()> const& trigger_trim);
, std::function<void()> const& trigger_trim);
~disk_buffer_pool();
#if TORRENT_USE_ASSERTS
@ -125,7 +124,7 @@ namespace libtorrent
std::vector<boost::weak_ptr<disk_observer>> m_observers;
// callback used to tell the cache it needs to free up some blocks
boost::function<void()> m_trigger_cache_trim;
std::function<void()> m_trigger_cache_trim;
// set to true to throttle more allocations
bool m_exceeded_max_size;

View File

@ -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<void(disk_io_job const*)> handler, void* requester
, std::function<void(disk_io_job const*)> handler, void* requester
, int flags = 0) = 0;
virtual void async_write(piece_manager* storage, peer_request const& r
, disk_buffer_holder buffer
, boost::function<void(disk_io_job const*)> handler
, std::function<void(disk_io_job const*)> handler
, int flags = 0) = 0;
virtual void async_hash(piece_manager* storage, int piece, int flags
, boost::function<void(disk_io_job const*)> handler, void* requester) = 0;
, std::function<void(disk_io_job const*)> handler, void* requester) = 0;
virtual void async_move_storage(piece_manager* storage, std::string const& p, int flags
, boost::function<void(disk_io_job const*)> handler) = 0;
, std::function<void(disk_io_job const*)> handler) = 0;
virtual void async_release_files(piece_manager* storage
, boost::function<void(disk_io_job const*)> handler
= boost::function<void(disk_io_job const*)>()) = 0;
, std::function<void(disk_io_job const*)> handler
= std::function<void(disk_io_job const*)>()) = 0;
virtual void async_check_files(piece_manager* storage
, add_torrent_params const* resume_data
, std::vector<std::string>& links
, boost::function<void(disk_io_job const*)> handler) = 0;
, std::function<void(disk_io_job const*)> handler) = 0;
#ifndef TORRENT_NO_DEPRECATE
virtual void async_cache_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> handler) = 0;
, std::function<void(disk_io_job const*)> handler) = 0;
virtual void async_finalize_file(piece_manager*, int file
, boost::function<void(disk_io_job const*)> handler
= boost::function<void(disk_io_job const*)>()) = 0;
, std::function<void(disk_io_job const*)> handler
= std::function<void(disk_io_job const*)>()) = 0;
#endif
virtual void async_flush_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> handler
= boost::function<void(disk_io_job const*)>()) = 0;
, std::function<void(disk_io_job const*)> handler
= std::function<void(disk_io_job const*)>()) = 0;
virtual void async_stop_torrent(piece_manager* storage
, boost::function<void(disk_io_job const*)> handler)= 0;
, std::function<void(disk_io_job const*)> handler)= 0;
virtual void async_rename_file(piece_manager* storage, int index, std::string const& name
, boost::function<void(disk_io_job const*)> handler) = 0;
, std::function<void(disk_io_job const*)> handler) = 0;
virtual void async_delete_files(piece_manager* storage, int options
, boost::function<void(disk_io_job const*)> handler) = 0;
, std::function<void(disk_io_job const*)> handler) = 0;
virtual void async_set_file_priority(piece_manager* storage
, std::vector<std::uint8_t> const& prio
, boost::function<void(disk_io_job const*)> handler) = 0;
, std::function<void(disk_io_job const*)> handler) = 0;
virtual void async_load_torrent(add_torrent_params* params
, boost::function<void(disk_io_job const*)> handler) = 0;
, std::function<void(disk_io_job const*)> handler) = 0;
virtual void async_tick_torrent(piece_manager* storage
, boost::function<void(disk_io_job const*)> handler) = 0;
, std::function<void(disk_io_job const*)> handler) = 0;
virtual void clear_read_cache(piece_manager* storage) = 0;
virtual void async_clear_piece(piece_manager* storage, int index
, boost::function<void(disk_io_job const*)> handler) = 0;
, std::function<void(disk_io_job const*)> handler) = 0;
virtual void clear_piece(piece_manager* storage, int index) = 0;
virtual void update_stats_counters(counters& c) const = 0;

View File

@ -164,7 +164,7 @@ namespace libtorrent
boost::shared_ptr<piece_manager> storage;
// this is called when operation completes
boost::function<void(disk_io_job const*)> callback;
std::function<void(disk_io_job const*)> callback;
// the error code from the file operation
// on error, this also contains the path of the

View File

@ -300,50 +300,50 @@ namespace libtorrent
void abort(bool wait);
void async_read(piece_manager* storage, peer_request const& r
, boost::function<void(disk_io_job const*)> handler, void* requester
, std::function<void(disk_io_job const*)> handler, void* requester
, int flags = 0) override;
void async_write(piece_manager* storage, peer_request const& r
, disk_buffer_holder buffer
, boost::function<void(disk_io_job const*)> handler
, std::function<void(disk_io_job const*)> handler
, int flags = 0) override;
void async_hash(piece_manager* storage, int piece, int flags
, boost::function<void(disk_io_job const*)> handler, void* requester) override;
, std::function<void(disk_io_job const*)> handler, void* requester) override;
void async_move_storage(piece_manager* storage, std::string const& p, int flags
, boost::function<void(disk_io_job const*)> handler) override;
, std::function<void(disk_io_job const*)> handler) override;
void async_release_files(piece_manager* storage
, boost::function<void(disk_io_job const*)> handler
= boost::function<void(disk_io_job const*)>()) override;
, std::function<void(disk_io_job const*)> handler
= std::function<void(disk_io_job const*)>()) override;
void async_delete_files(piece_manager* storage, int options
, boost::function<void(disk_io_job const*)> handler) override;
, std::function<void(disk_io_job const*)> handler) override;
void async_check_files(piece_manager* storage
, add_torrent_params const* resume_data
, std::vector<std::string>& links
, boost::function<void(disk_io_job const*)> handler) override;
, std::function<void(disk_io_job const*)> handler) override;
void async_rename_file(piece_manager* storage, int index, std::string const& name
, boost::function<void(disk_io_job const*)> handler) override;
, std::function<void(disk_io_job const*)> handler) override;
void async_stop_torrent(piece_manager* storage
, boost::function<void(disk_io_job const*)> handler) override;
, std::function<void(disk_io_job const*)> handler) override;
#ifndef TORRENT_NO_DEPRECATE
void async_cache_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> handler) override;
, std::function<void(disk_io_job const*)> handler) override;
void async_finalize_file(piece_manager* storage, int file
, boost::function<void(disk_io_job const*)> handler
= boost::function<void(disk_io_job const*)>()) override;
, std::function<void(disk_io_job const*)> handler
= std::function<void(disk_io_job const*)>()) override;
#endif
void async_flush_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> handler
= boost::function<void(disk_io_job const*)>()) override;
, std::function<void(disk_io_job const*)> handler
= std::function<void(disk_io_job const*)>()) override;
void async_set_file_priority(piece_manager* storage
, std::vector<std::uint8_t> const& prio
, boost::function<void(disk_io_job const*)> handler) override;
, std::function<void(disk_io_job const*)> handler) override;
void async_load_torrent(add_torrent_params* params
, boost::function<void(disk_io_job const*)> handler) override;
, std::function<void(disk_io_job const*)> handler) override;
void async_tick_torrent(piece_manager* storage
, boost::function<void(disk_io_job const*)> handler) override;
, std::function<void(disk_io_job const*)> handler) override;
void clear_read_cache(piece_manager* storage) override;
void async_clear_piece(piece_manager* storage, int index
, boost::function<void(disk_io_job const*)> handler) override;
, std::function<void(disk_io_job const*)> 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.

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <memory>
#include <string>
#include <functional>
#include "libtorrent/config.hpp"
#include "libtorrent/string_view.hpp"
@ -43,7 +44,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/noncopyable.hpp>
#include <boost/smart_ptr.hpp>
#include <boost/function.hpp>
#ifdef TORRENT_WINDOWS
// windows part

View File

@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/function.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/noncopyable.hpp>
@ -45,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <functional>
#include <vector>
#include <string>
@ -65,12 +65,12 @@ struct resolver_interface;
const int default_max_bottled_buffer_size = 2 * 1024 * 1024;
typedef boost::function<void(error_code const&
typedef std::function<void(error_code const&
, http_parser const&, char const* data, int size, http_connection&)> http_handler;
typedef boost::function<void(http_connection&)> http_connect_handler;
typedef std::function<void(http_connection&)> http_connect_handler;
typedef boost::function<void(http_connection&, std::vector<tcp::endpoint>&)> http_filter_handler;
typedef std::function<void(http_connection&, std::vector<tcp::endpoint>&)> http_filter_handler;
// when bottled, the last two arguments to the handler
// will always be 0

View File

@ -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<void(std::vector<tcp::endpoint> const&)> f);
, std::function<void(std::vector<tcp::endpoint> const&)> f);
void announce(sha1_hash const& ih, int listen_port, int flags
, boost::function<void(std::vector<tcp::endpoint> const&)> f);
, std::function<void(std::vector<tcp::endpoint> const&)> f);
void get_item(sha1_hash const& target
, boost::function<void(item const&)> cb);
, std::function<void(item const&)> 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<void(item const&, bool)> cb
, std::function<void(item const&, bool)> 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<void(int)> cb);
, std::function<void(int)> 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<void(item const&, int)> cb
, boost::function<void(item&)> data_cb, std::string salt = std::string());
, std::function<void(item const&, int)> cb
, std::function<void(item&)> 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<void(msg const&)> f);
, std::function<void(msg const&)> f);
#ifndef TORRENT_NO_DEPRECATE
void dht_status(session_status& s);

View File

@ -42,7 +42,7 @@ namespace libtorrent { namespace dht
struct direct_traversal : traversal_algorithm
{
typedef boost::function<void(dht::msg const&)> message_callback;
typedef std::function<void(dht::msg const&)> 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();
}
}

View File

@ -63,7 +63,7 @@ class node;
struct find_data : traversal_algorithm
{
typedef boost::function<void(std::vector<std::pair<node_entry, std::string> > const&)> nodes_callback;
typedef std::function<void(std::vector<std::pair<node_entry, std::string> > const&)> nodes_callback;
find_data(node& node, node_id target
, nodes_callback const& ncallback);

View File

@ -43,7 +43,7 @@ namespace libtorrent { namespace dht
class get_item : public find_data
{
public:
typedef boost::function<void(item const&, bool)> data_callback;
typedef std::function<void(item const&, bool)> data_callback;
void got_data(bdecode_node const& v,
public_key const& pk,

View File

@ -40,7 +40,7 @@ namespace libtorrent { namespace dht
struct get_peers : find_data
{
typedef boost::function<void(std::vector<tcp::endpoint> const&)> data_callback;
typedef std::function<void(std::vector<tcp::endpoint> const&)> data_callback;
void got_peers(std::vector<tcp::endpoint> const& peers);

View File

@ -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<void(std::vector<tcp::endpoint> const&)> dcallback
, boost::function<void(std::vector<std::pair<node_entry, std::string> > const&)> ncallback
, std::function<void(std::vector<tcp::endpoint> const&)> dcallback
, std::function<void(std::vector<std::pair<node_entry, std::string> > const&)> ncallback
, bool noseeds);
void announce(sha1_hash const& info_hash, int listen_port, int flags
, boost::function<void(std::vector<tcp::endpoint> const&)> f);
, std::function<void(std::vector<tcp::endpoint> const&)> f);
void direct_request(udp::endpoint ep, entry& e
, boost::function<void(msg const&)> f);
, std::function<void(msg const&)> f);
void get_item(sha1_hash const& target, boost::function<void(item const&)> f);
void get_item(public_key const& pk, std::string const& salt, boost::function<void(item const&, bool)> f);
void get_item(sha1_hash const& target, std::function<void(item const&)> f);
void get_item(public_key const& pk, std::string const& salt, std::function<void(item const&, bool)> f);
void put_item(sha1_hash const& target, entry const& data, boost::function<void(int)> f);
void put_item(sha1_hash const& target, entry const& data, std::function<void(int)> f);
void put_item(public_key const& pk, std::string const& salt
, boost::function<void(item const&, int)> f
, boost::function<void(item&)> data_cb);
, std::function<void(item const&, int)> f
, std::function<void(item&)> data_cb);
bool verify_token(string_view token, sha1_hash const& info_hash
, udp::endpoint const& addr) const;

View File

@ -53,7 +53,7 @@ class node;
struct put_data: traversal_algorithm
{
typedef boost::function<void(item const&, int)> put_callback;
typedef std::function<void(item const&, int)> put_callback;
put_data(node& node, put_callback const& callback);

View File

@ -54,9 +54,9 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
typedef boost::function<void(tcp::endpoint, sha1_hash)> peer_callback_t;
typedef std::function<void(tcp::endpoint, sha1_hash)> peer_callback_t;
#ifndef TORRENT_DISABLE_LOGGING
typedef boost::function<void(char const*)> log_callback_t;
typedef std::function<void(char const*)> log_callback_t;
#endif
class lsd : public boost::enable_shared_from_this<lsd>

View File

@ -55,8 +55,8 @@ namespace libtorrent
// int: port mapping index
// int: external port
// std::string: error message
typedef boost::function<void(int, address, int, int, error_code const&)> portmap_callback_t;
typedef boost::function<void(char const*)> log_callback_t;
typedef std::function<void(int, address, int, int, error_code const&)> portmap_callback_t;
typedef std::function<void(char const*)> log_callback_t;
struct TORRENT_EXTRA_EXPORT natpmp
: boost::enable_shared_from_this<natpmp>

View File

@ -50,7 +50,7 @@ class proxy_base : boost::noncopyable
{
public:
typedef boost::function<void(error_code const&)> handler_type;
typedef std::function<void(error_code const&)> handler_type;
typedef tcp::socket next_layer_type;
typedef tcp::socket::lowest_layer_type lowest_layer_type;

View File

@ -36,12 +36,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/asio/ip/tcp.hpp>
#include <boost/function.hpp>
#include <boost/unordered_map.hpp>
#include <vector>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <unordered_map>
#include <functional>
#include <vector>
#include "libtorrent/error_code.hpp"
#include "libtorrent/io_service.hpp"
#include "libtorrent/socket.hpp"
@ -72,7 +73,7 @@ private:
std::vector<address> addresses;
};
typedef boost::unordered_map<std::string, dns_cache_entry> cache_t;
using cache_t = std::unordered_map<std::string, dns_cache_entry>;
cache_t m_cache;
io_service& m_ios;

View File

@ -34,21 +34,17 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_RESOLVER_INTERFACE_HPP_INCLUDE
#include <vector>
#include <functional>
#include "libtorrent/error_code.hpp"
#include "libtorrent/address.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/function.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent
{
struct TORRENT_EXTRA_EXPORT resolver_interface
{
typedef boost::function<void(error_code const&, std::vector<address> const&)>
typedef std::function<void(error_code const&, std::vector<address> const&)>
callback_t;
enum flags_t

View File

@ -58,7 +58,7 @@ namespace libtorrent
struct session_status;
#endif
typedef boost::function<void(sha1_hash const&, std::vector<char>&
typedef std::function<void(sha1_hash const&, std::vector<char>&
, 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<torrent_status>* ret
, boost::function<bool(torrent_status const&)> const& pred
, std::function<bool(torrent_status const&)> const& pred
, std::uint32_t flags = 0) const;
void refresh_torrent_status(std::vector<torrent_status>* 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<char, 32> key
, boost::function<void(entry&, std::array<char,64>&
, std::function<void(entry&, std::array<char,64>&
, 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<boost::shared_ptr<torrent_plugin>(
void add_extension(std::function<boost::shared_ptr<torrent_plugin>(
torrent_handle const&, void*)> ext);
void add_extension(boost::shared_ptr<plugin> ext);
@ -942,7 +942,7 @@ namespace libtorrent
// It really should just notify the main application thread.
void pop_alerts(std::vector<alert*>* alerts);
alert* wait_for_alert(time_duration max_wait);
void set_alert_notify(boost::function<void()> const& fun);
void set_alert_notify(std::function<void()> const& fun);
#ifndef TORRENT_NO_DEPRECATE
TORRENT_DEPRECATED

View File

@ -100,7 +100,7 @@ public:
SSL* native_handle() { return m_sock.native_handle(); }
#endif
typedef boost::function<void(error_code const&)> handler_type;
typedef std::function<void(error_code const&)> handler_type;
template <class Handler>
void async_connect(endpoint_type const& endpoint, Handler const& handler)

View File

@ -300,7 +300,7 @@ namespace libtorrent
#ifndef TORRENT_DISABLE_EXTENSIONS
void add_extension(boost::shared_ptr<torrent_plugin>);
void remove_extension(boost::shared_ptr<torrent_plugin>);
void add_extension_fun(boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
void add_extension_fun(std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
, void* userdata);
void notify_extension_add_peer(tcp::endpoint const& ip, int src, int flags);
#endif

View File

@ -37,10 +37,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include <set>
#include <functional>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/weak_ptr.hpp>
#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<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
, void* userdata = 0);
// ``set_metadata`` expects the *info* section of metadata. i.e. The

View File

@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <utility>
#include <cstdint>
#include <tuple>
#include <functional>
#include "libtorrent/aux_/disable_warnings_push.hpp"
@ -48,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/enable_shared_from_this.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/unordered_map.hpp>
#include <boost/function.hpp>
#ifdef TORRENT_USE_OPENSSL
#include <boost/asio/ssl/context.hpp>
@ -341,10 +341,10 @@ namespace libtorrent
{
public:
typedef boost::function<void(udp::endpoint const&
typedef std::function<void(udp::endpoint const&
, span<char const>
, error_code&, int)> send_fun_t;
typedef boost::function<void(char const*, int
typedef std::function<void(char const*, int
, span<char const>
, error_code&, int)> send_fun_hostname_t;

View File

@ -42,11 +42,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/resolver.hpp"
#include "libtorrent/debug.hpp"
#include <boost/function/function1.hpp>
#include <boost/function/function5.hpp>
#include <boost/noncopyable.hpp>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <functional>
#include <set>
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<void(int, address, int, int, error_code const&)> portmap_callback_t;
typedef boost::function<void(char const*)> log_callback_t;
typedef std::function<void(int, address, int, int, error_code const&)> portmap_callback_t;
typedef std::function<void(char const*)> log_callback_t;
struct parse_state
{

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_UTP_SOCKET_MANAGER_HPP_INCLUDED
#include <map>
#include <functional>
#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 <boost/function.hpp>
#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<void(udp::endpoint const&
typedef std::function<void(udp::endpoint const&
, span<char const>
, error_code&, int)> send_fun_t;
typedef boost::function<void(boost::shared_ptr<socket_type> const&)>
typedef std::function<void(boost::shared_ptr<socket_type> const&)>
incoming_utp_callback_t;
utp_socket_manager(send_fun_t const& send_fun

View File

@ -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 <functional>
#include <boost/function/function1.hpp>
#include <boost/function/function2.hpp>
#ifndef BOOST_NO_EXCEPTIONS
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/system/system_error.hpp>
#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<void(error_code const&)> const& handler);
, std::function<void(error_code const&)> const& handler);
template <class Protocol>
void open(Protocol const&, error_code&)
@ -493,9 +489,9 @@ private:
void cancel_handlers(error_code const&);
boost::function1<void, error_code const&> m_connect_handler;
boost::function2<void, error_code const&, std::size_t> m_read_handler;
boost::function2<void, error_code const&, std::size_t> m_write_handler;
std::function<void(error_code const&)> m_connect_handler;
std::function<void(error_code const&, std::size_t)> m_read_handler;
std::function<void(error_code const&, std::size_t)> m_write_handler;
io_service& m_io_service;
utp_socket_impl* m_impl;

View File

@ -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 <boost/function.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <functional>
#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<char const> input
, boost::function<void(int,char const*,int,char const*,int)> callback);
, std::function<void(int,char const*,int,char const*,int)> callback);
}

View File

@ -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<sim::asio::io_service>(
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<lt::session> ses =
boost::make_shared<lt::session>(pack
, boost::ref(*io_service.back()));
, std::ref(*io_service.back()));
init_session(*ses);
nodes.push_back(ses);

View File

@ -111,7 +111,7 @@ TORRENT_TEST(dht_rate_limit)
entry state;
std::unique_ptr<lt::dht::dht_storage_interface> dht_storage(dht::dht_default_storage_constructor(dhtsett));
boost::shared_ptr<lt::dht::dht_tracker> dht = boost::make_shared<lt::dht::dht_tracker>(
&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;

View File

@ -71,7 +71,7 @@ boost::shared_ptr<torrent_info> create_torrent(file_storage& fs)
bencode(out, tor);
error_code ec;
return boost::make_shared<torrent_info>(
&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

View File

@ -93,7 +93,7 @@ namespace libtorrent
#endif
}
void alert_manager::set_notify_function(boost::function<void()> const& fun)
void alert_manager::set_notify_function(std::function<void()> const& fun)
{
std::unique_lock<std::mutex> lock(m_mutex);
m_notify = fun;

View File

@ -349,7 +349,7 @@ cached_piece_entry::~cached_piece_entry()
}
block_cache::block_cache(int block_size, io_service& ios
, boost::function<void()> const& trigger_trim)
, std::function<void()> const& trigger_trim)
: disk_buffer_pool(block_size, ios, trigger_trim)
, m_last_cache_op(cache_miss)
, m_ghost_size(8)

View File

@ -117,7 +117,7 @@ namespace libtorrent
}
void add_files_impl(file_storage& fs, std::string const& p
, std::string const& l, boost::function<bool(std::string)> pred, std::uint32_t flags)
, std::string const& l, std::function<bool(std::string)> 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<piece_manager> storage, disk_io_thread* iothread
, int* piece_counter, int* completed_piece
, boost::function<void(int)> const* f, error_code* ec)
, std::function<void(int)> 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<bool(std::string)> p, std::uint32_t flags)
, std::function<bool(std::string)> 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<void(int)> f, error_code& ec)
, std::function<void(int)> 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<void(int)> f, error_code& ec)
, std::function<void(int)> 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<bool(std::string)> p, std::uint32_t flags)
, std::function<bool(std::string)> 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<void(int)> const& f, error_code& ec)
, std::function<void(int)> const& f, error_code& ec)
{
// optimized path
io_service ios;

View File

@ -79,7 +79,7 @@ namespace libtorrent
} // anonymous namespace
disk_buffer_pool::disk_buffer_pool(int block_size, io_service& ios
, boost::function<void()> const& trigger_trim)
, std::function<void()> const& trigger_trim)
: m_block_size(block_size)
, m_in_use(0)
, m_max_use(64)

View File

@ -1479,7 +1479,7 @@ namespace libtorrent
}
void disk_io_thread::async_read(piece_manager* storage, peer_request const& r
, boost::function<void(disk_io_job const*)> handler, void* requester
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler, void* requester)
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> 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<std::string>& links
, boost::function<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> handler)
{
// remove outstanding hash jobs belonging to this torrent
std::unique_lock<std::mutex> 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<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> 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<std::uint8_t> const& prios
, boost::function<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> handler)
{
disk_io_job* j = allocate_job(disk_io_job::load_torrent);
j->requester = reinterpret_cast<char*>(params);
@ -2001,7 +2001,7 @@ namespace libtorrent
}
void disk_io_thread::async_tick_torrent(piece_manager* storage
, boost::function<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> 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<void(disk_io_job const*)> handler)
, std::function<void(disk_io_job const*)> handler)
{
#if TORRENT_USE_ASSERTS
// the caller must increment the torrent refcount before

View File

@ -32,18 +32,14 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/version.hpp>
#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 <limits>
namespace libtorrent
{
file_pool::file_pool(int size)
@ -230,7 +226,8 @@ namespace libtorrent
std::unique_lock<std::mutex> 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<int>::max()));
for (file_set::const_iterator i = start; i != end; ++i)
{

View File

@ -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;
}

View File

@ -331,9 +331,9 @@ namespace libtorrent { namespace dht
}
void dht_tracker::get_peers(sha1_hash const& ih
, boost::function<void(std::vector<tcp::endpoint> const&)> f)
, std::function<void(std::vector<tcp::endpoint> const&)> f)
{
boost::function<void(std::vector<std::pair<node_entry, std::string> > const&)> empty;
std::function<void(std::vector<std::pair<node_entry, std::string> > 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<void(std::vector<tcp::endpoint> const&)> f)
, std::function<void(std::vector<tcp::endpoint> 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<get_immutable_item_ctx> ctx
, boost::function<void(item const&)> f)
, std::function<void(item const&)> 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<get_mutable_item_ctx> ctx
, boost::function<void(item const&, bool)> f)
, std::function<void(item const&, bool)> 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<put_item_ctx> ctx
, boost::function<void(int)> f)
, std::function<void(int)> 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<put_item_ctx> ctx
, boost::function<void(item const&, int)> cb)
, std::function<void(item const&, int)> 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<void(item const&)> cb)
, std::function<void(item const&)> cb)
{
boost::shared_ptr<get_immutable_item_ctx>
ctx = boost::make_shared<get_immutable_item_ctx>((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<void(item const&, bool)> cb
, std::function<void(item const&, bool)> cb
, std::string salt)
{
boost::shared_ptr<get_mutable_item_ctx>
@ -457,7 +455,7 @@ namespace libtorrent { namespace dht
}
void dht_tracker::put_item(entry const& data
, boost::function<void(int)> cb)
, std::function<void(int)> 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<void(item const&, int)> cb
, boost::function<void(item&)> data_cb, std::string salt)
, std::function<void(item const&, int)> cb
, std::function<void(item&)> data_cb, std::string salt)
{
boost::shared_ptr<put_item_ctx>
ctx = boost::make_shared<put_item_ctx>((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<void(msg const&)> f)
, std::function<void(msg const&)> f)
{
#if TORRENT_USE_IPV6
if (ep.protocol() == udp::v6())

View File

@ -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 "

View File

@ -424,8 +424,8 @@ void node::add_node(udp::endpoint node)
}
void node::get_peers(sha1_hash const& info_hash
, boost::function<void(std::vector<tcp::endpoint> const&)> dcallback
, boost::function<void(std::vector<std::pair<node_entry, std::string> > const&)> ncallback
, std::function<void(std::vector<tcp::endpoint> const&)> dcallback
, std::function<void(std::vector<std::pair<node_entry, std::string> > 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<void(std::vector<tcp::endpoint> const&)> f)
, std::function<void(std::vector<tcp::endpoint> 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<void(msg const&)> f)
, std::function<void(msg const&)> f)
{
// not really a traversal
boost::intrusive_ptr<direct_traversal> algo(
@ -479,7 +479,7 @@ void node::direct_request(udp::endpoint ep, entry& e
}
void node::get_item(sha1_hash const& target
, boost::function<void(item const&)> f)
, std::function<void(item const&)> 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<void(item const&, bool)> f)
, std::function<void(item const&, bool)> f)
{
#ifndef TORRENT_DISABLE_LOGGING
if (m_observer)
@ -524,7 +524,7 @@ void put(std::vector<std::pair<node_entry, std::string> > const& nodes
void put_data_cb(item i, bool auth
, boost::intrusive_ptr<put_data> ta
, boost::function<void(item&)> f)
, std::function<void(item&)> 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<void(int)> f)
void node::put_item(sha1_hash const& target, entry const& data, std::function<void(int)> 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<void(item const&, int)> f
, boost::function<void(item&)> data_cb)
, std::function<void(item const&, int)> f
, std::function<void(item&)> data_cb)
{
#ifndef TORRENT_DISABLE_LOGGING
if (m_observer)

View File

@ -307,7 +307,7 @@ void lsd::close()
#if TORRENT_USE_IPV6
m_disabled6 = true;
#endif
m_callback.clear();
m_callback = nullptr;
}
} // libtorrent namespace

View File

@ -300,7 +300,7 @@ namespace libtorrent
ios = m_io_service.get();
}
m_impl = boost::make_shared<session_impl>(boost::ref(*ios));
m_impl = boost::make_shared<session_impl>(std::ref(*ios));
*static_cast<session_handle*>(this) = session_handle(m_impl.get());
#ifndef TORRENT_DISABLE_EXTENSIONS

View File

@ -106,7 +106,7 @@ namespace libtorrent
}
void session_handle::get_torrent_status(std::vector<torrent_status>* ret
, boost::function<bool(torrent_status const&)> const& pred
, std::function<bool(torrent_status const&)> 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<char, 32> key
, boost::function<void(entry&, std::array<char,64>&
, std::function<void(entry&, std::array<char,64>&
, 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<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> ext)
void session_handle::add_extension(std::function<boost::shared_ptr<torrent_plugin>(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<void()> const& fun)
void session_handle::set_alert_notify(std::function<void()> const& fun)
{
m_impl->alerts().set_notify_function(fun);
}

View File

@ -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>(
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<tcp::acceptor>(boost::ref(m_io_service));
ret.sock = boost::make_shared<tcp::acceptor>(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<udp_socket>(boost::ref(m_io_service));
ret.udp_sock = boost::make_shared<udp_socket>(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<socket_type>(boost::ref(m_io_service));
m_socks_listen_socket = boost::make_shared<socket_type>(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<torrent_status>* ret
, boost::function<bool(torrent_status const&)> const& pred
, std::function<bool(torrent_status const&)> 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<torrent_info> t = boost::make_shared<torrent_info>(filename, boost::ref(ec), 0);
boost::shared_ptr<torrent_info> t = boost::make_shared<torrent_info>(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<torrent>(boost::ref(*this)
torrent_ptr = boost::make_shared<torrent>(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<dht::dht_tracker>(
static_cast<dht_observer*>(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<void(entry&, std::array<char, 64>&
, std::function<void(entry&, std::array<char, 64>&
, 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<char, 32> key
, boost::function<void(entry&, std::array<char,64>&
, std::function<void(entry&, std::array<char,64>&
, 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<lsd>(boost::ref(m_io_service)
m_lsd = boost::make_shared<lsd>(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<natpmp>(boost::ref(m_io_service)
m_natpmp = boost::make_shared<natpmp>(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<upnp>(boost::ref(m_io_service)
m_upnp = boost::make_shared<upnp>(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)

View File

@ -466,7 +466,7 @@ namespace libtorrent
}
error_code e;
boost::shared_ptr<torrent_info> tf(boost::make_shared<torrent_info>(data, size, boost::ref(e), 0));
boost::shared_ptr<torrent_info> tf(boost::make_shared<torrent_info>(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<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
void torrent::add_extension_fun(std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
, void* userdata)
{
boost::shared_ptr<torrent_plugin> 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<context> ctx = boost::make_shared<context>(boost::ref(m_ses.get_io_service()), context::sslv23);
boost::shared_ptr<context> ctx = boost::make_shared<context>(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<void(disk_io_job const*)>());
, std::function<void(disk_io_job const*)>());
// 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<socket_type> s
= boost::make_shared<socket_type>(boost::ref(m_ses.get_io_service()));
= boost::make_shared<socket_type>(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<web_peer_connection>(
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<http_seed_connection>(
boost::cref(pack), boost::ref(*web));
boost::cref(pack), std::ref(*web));
}
if (!c) return;

View File

@ -206,7 +206,7 @@ namespace libtorrent
}
void torrent_handle::add_extension(
boost::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
std::function<boost::shared_ptr<torrent_plugin>(torrent_handle const&, void*)> const& ext
, void* userdata)
{
#ifndef TORRENT_DISABLE_EXTENSIONS

View File

@ -289,7 +289,7 @@ namespace libtorrent
{
boost::shared_ptr<http_tracker_connection> con
= boost::make_shared<http_tracker_connection>(
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<udp_tracker_connection> con
= boost::make_shared<udp_tracker_connection>(
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;

View File

@ -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<socks5>(boost::ref(m_socket.get_io_service()));
m_socks5_connection = boost::make_shared<socks5>(std::ref(m_socket.get_io_service()));
m_socks5_connection->start(ps);
}
}

View File

@ -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<char const> 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;

View File

@ -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<void>(s->m_read_handler, ec, bytes_transferred));
s->m_read_handler.clear();
// boost::function2<void, error_code const&, std::size_t> 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<void>(s->m_write_handler, ec, bytes_transferred));
s->m_write_handler.clear();
// boost::function2<void, error_code const&, std::size_t> 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<void>(s->m_connect_handler, ec));
s->m_connect_handler.clear();
// boost::function1<void, error_code const&> 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)

View File

@ -39,7 +39,7 @@ namespace libtorrent
{
TORRENT_EXTRA_EXPORT void xml_parse(span<char const> input
, boost::function<void(int,char const*,int,char const*,int)> callback)
, std::function<void(int,char const*,int,char const*,int)> callback)
{
char const* p = input.data();
char const* end = input.data() + input.size();

View File

@ -47,7 +47,7 @@ using namespace libtorrent;
using namespace std::placeholders;
peer_conn::peer_conn(io_service& ios
, boost::function<void(int, char const*, int)> on_msg
, std::function<void(int, char const*, int)> on_msg
, torrent_info const& ti
, tcp::endpoint const& ep
, peer_mode_t mode)

View File

@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/address.hpp"
#include "libtorrent/torrent_info.hpp"
#include "test.hpp" // for EXPORT
#include <boost/function.hpp>
#include <functional>
using namespace libtorrent;
@ -50,7 +50,7 @@ struct EXPORT peer_conn
{ uploader, downloader, idle };
peer_conn(io_service& ios
, boost::function<void(int, char const*, int)> on_msg
, std::function<void(int, char const*, int)> 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<void(int, char const*, int)> m_on_msg;
std::function<void(int, char const*, int)> m_on_msg;
enum state_t
{

View File

@ -758,7 +758,7 @@ boost::shared_ptr<torrent_info> create_torrent(std::ostream* file
bencode(out, tor);
error_code ec;
return boost::make_shared<torrent_info>(
&tmp[0], tmp.size(), boost::ref(ec), 0);
&tmp[0], tmp.size(), std::ref(ec), 0);
}
std::tuple<torrent_handle, torrent_handle, torrent_handle>

View File

@ -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);

View File

@ -41,9 +41,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/time.hpp"
#include "libtorrent/aux_/session_settings.hpp"
#include <boost/function.hpp>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <cmath>
#include <functional>
@ -153,7 +154,7 @@ static void nop() {}
void run_test(connections_t& v
, bandwidth_manager& manager
, boost::function<void()> f = &nop)
, std::function<void()> 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;

View File

@ -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);

View File

@ -139,7 +139,7 @@ boost::shared_ptr<default_storage> setup_torrent(file_storage& fs
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&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<char> buf;
bencode(std::back_inserter(buf), t.generate());
info = boost::make_shared<torrent_info>(&buf[0], buf.size(), boost::ref(ec), 0);
info = boost::make_shared<torrent_info>(&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<char> buf;
bencode(std::back_inserter(buf), t.generate());
info = boost::make_shared<torrent_info>(&buf[0], buf.size(), boost::ref(ec), 0);
info = boost::make_shared<torrent_info>(&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<char> buf;
bencode(std::back_inserter(buf), t.generate());
info = boost::make_shared<torrent_info>(&buf[0], buf.size(), boost::ref(ec), 0);
info = boost::make_shared<torrent_info>(&buf[0], buf.size(), std::ref(ec), 0);
std::cerr << "=== test 3 ===" << std::endl;

View File

@ -171,7 +171,7 @@ TORRENT_TEST(long_names)
std::vector<char> buf;
bencode(std::back_inserter(buf), torrent);
error_code ec;
boost::shared_ptr<torrent_info> ti(boost::make_shared<torrent_info>(&buf[0], buf.size(), boost::ref(ec)));
boost::shared_ptr<torrent_info> ti(boost::make_shared<torrent_info>(&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<torrent_info> info(boost::make_shared<torrent_info>(
&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<torrent_info> info(boost::make_shared<torrent_info>(
&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<std::vector<char> > out(tmp);
bencode(out, t.generate());
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&tmp[0], tmp.size(), boost::ref(ec), 0));
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&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<std::vector<char> > out(tmp);
bencode(out, t.generate());
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&tmp[0], tmp.size(), boost::ref(ec), 0));
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&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<torrent_info>(&tmp[0], tmp.size(), boost::ref(ec), 0);
p.ti = boost::make_shared<torrent_info>(&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<std::vector<char> > out(tmp);
bencode(out, t.generate());
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&tmp[0], tmp.size(), boost::ref(ec), 0));
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&tmp[0], tmp.size(), std::ref(ec), 0));
TEST_EQUAL(info->files().file_path(0), combine_path("test3","tmp1"));

View File

@ -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> upnp_handler(new upnp(boost::ref(ios)
boost::shared_ptr<upnp> upnp_handler(new upnp(std::ref(ios)
, user_agent, &callback, &log_callback, false));
upnp_handler->start();
upnp_handler->discover_device();

View File

@ -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;