diff --git a/ChangeLog b/ChangeLog index 3df36021b..27cdfff5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * source code migration from boost::shared_ptr to std::shared_ptr * storage_interface API changed to use span and references * changes in public API to work with std::shared_ptr * extensions API changed to use span and std::shared_ptr diff --git a/bindings/c/library.cpp b/bindings/c/library.cpp index 9ac20dc42..c438b20d3 100644 --- a/bindings/c/library.cpp +++ b/bindings/c/library.cpp @@ -60,7 +60,7 @@ namespace int add_handle(libtorrent::torrent_handle const& h) { std::vector::iterator i = std::find_if(handles.begin() - , handles.end(), !boost::bind(&libtorrent::torrent_handle::is_valid, _1)); + , handles.end(), !std::bind(&libtorrent::torrent_handle::is_valid, _1)); if (i != handles.end()) { *i = h; diff --git a/bindings/python/src/entry.cpp b/bindings/python/src/entry.cpp index db43b5b1b..db3179256 100644 --- a/bindings/python/src/entry.cpp +++ b/bindings/python/src/entry.cpp @@ -59,7 +59,7 @@ struct entry_to_python } } - static PyObject* convert(boost::shared_ptr const& e) + static PyObject* convert(std::shared_ptr const& e) { if (!e) return incref(Py_None); @@ -172,7 +172,7 @@ struct entry_from_python void bind_entry() { - to_python_converter, entry_to_python>(); + to_python_converter, entry_to_python>(); to_python_converter(); entry_from_python(); } diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 6be3599eb..c5ab4cf32 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -138,11 +138,11 @@ namespace } } - boost::shared_ptr make_session(boost::python::dict sett, int flags) + std::shared_ptr make_session(boost::python::dict sett, int flags) { settings_pack p; make_settings_pack(p, sett); - return boost::make_shared(p, flags); + return std::make_shared(p, flags); } #ifndef TORRENT_NO_DEPRECATE diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index a68cf4998..cddadc6ce 100644 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -2,12 +2,8 @@ // subject to the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#include "libtorrent/aux_/disable_warnings_push.hpp" - #include "boost_python.hpp" -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" +#include #include "libtorrent/torrent_info.hpp" #include "libtorrent/session_settings.hpp" @@ -142,39 +138,39 @@ namespace } // namespace unnamed -boost::shared_ptr buffer_constructor0(char const* buf, int len, int flags) +std::shared_ptr buffer_constructor0(char const* buf, int len, int flags) { error_code ec; - boost::shared_ptr ret(boost::make_shared(buf - , len, boost::ref(ec), flags)); + std::shared_ptr ret = std::make_shared(buf + , len, ec, flags); #ifndef BOOST_NO_EXCEPTIONS if (ec) throw system_error(ec); #endif return ret; } -boost::shared_ptr buffer_constructor1(char const* buf, int len) +std::shared_ptr buffer_constructor1(char const* buf, int len) { return buffer_constructor0(buf, len, 0); } -boost::shared_ptr file_constructor0(std::string const& filename, int flags) +std::shared_ptr file_constructor0(std::string const& filename, int flags) { error_code ec; - boost::shared_ptr ret(boost::make_shared(filename - , boost::ref(ec), flags)); + std::shared_ptr ret = std::make_shared(filename + , ec, flags); #ifndef BOOST_NO_EXCEPTIONS if (ec) throw system_error(ec); #endif return ret; } -boost::shared_ptr file_constructor1(std::string const& filename) +std::shared_ptr file_constructor1(std::string const& filename) { return file_constructor0(filename, 0); } -boost::shared_ptr bencoded_constructor0(entry const& ent, int flags) +std::shared_ptr bencoded_constructor0(entry const& ent, int flags) { std::vector buf; bencode(std::back_inserter(buf), ent); @@ -188,15 +184,15 @@ boost::shared_ptr bencoded_constructor0(entry const& ent, int flag #endif } - boost::shared_ptr ret(boost::make_shared(e - , boost::ref(ec), flags)); + std::shared_ptr ret = std::make_shared(e + , ec, flags); #ifndef BOOST_NO_EXCEPTIONS if (ec) throw system_error(ec); #endif return ret; } -boost::shared_ptr bencoded_constructor1(entry const& ent) +std::shared_ptr bencoded_constructor1(entry const& ent) { return bencoded_constructor0(ent, 0); } @@ -216,7 +212,7 @@ void bind_torrent_info() .def_readwrite("size", &file_slice::size) ; - class_ >("torrent_info", no_init) + class_ >("torrent_info", no_init) .def(init((arg("info_hash"), arg("flags") = 0))) .def("__init__", make_constructor(&bencoded_constructor0)) .def("__init__", make_constructor(&bencoded_constructor1)) @@ -314,10 +310,8 @@ void bind_torrent_info() .value("source_tex", announce_entry::source_tex) ; -#if BOOST_VERSION > 104200 - implicitly_convertible, boost::shared_ptr >(); - boost::python::register_ptr_to_python >(); -#endif + implicitly_convertible, std::shared_ptr>(); + boost::python::register_ptr_to_python>(); } #ifdef _MSC_VER diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 3d88381f1..1c422ffee 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -215,7 +215,7 @@ The save_resume_data_alert_ looks something like this: virtual std::string message() const; // points to the resume data. - boost::shared_ptr resume_data; + std::shared_ptr resume_data; }; ``resume_data`` points to an entry_ object. This represents a node or a tree of diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 00f1a7e28..4259d17c2 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -989,7 +989,7 @@ namespace libtorrent { // internal save_resume_data_alert(aux::stack_allocator& alloc - , boost::shared_ptr const& rd + , std::shared_ptr const& rd , torrent_handle const& h); TORRENT_DEFINE_ALERT_PRIO(save_resume_data_alert, 37) @@ -998,7 +998,7 @@ namespace libtorrent virtual std::string message() const override; // points to the resume data. - boost::shared_ptr resume_data; + std::shared_ptr resume_data; }; // This alert is generated instead of ``save_resume_data_alert`` if there was an error @@ -1170,7 +1170,7 @@ namespace libtorrent // // torrent_handle h = alert->handle(); // if (h.is_valid()) { - // boost::shared_ptr ti = h.torrent_file(); + // std::shared_ptr ti = h.torrent_file(); // create_torrent ct(*ti); // entry te = ct.generate(); // std::vector buffer; diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index f3475864e..e6bc2f019 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -203,7 +203,7 @@ namespace libtorrent #if TORRENT_USE_INVARIANT_CHECKS friend class libtorrent::invariant_access; #endif - typedef std::set> connection_map; + typedef std::set> connection_map; typedef std::unordered_map> torrent_map; session_impl(io_service& ios); @@ -311,7 +311,7 @@ namespace libtorrent libtorrent::session_settings deprecated_settings() const; #endif - void apply_settings_pack(boost::shared_ptr pack) override; + void apply_settings_pack(std::shared_ptr pack) override; void apply_settings_pack_impl(settings_pack const& pack , bool const init = false); session_settings const& settings() const override { return m_settings; } @@ -395,7 +395,7 @@ namespace libtorrent void pause(); void resume(); - void set_ip_filter(boost::shared_ptr const& f); + void set_ip_filter(std::shared_ptr const& f); ip_filter const& get_ip_filter(); void set_port_filter(port_filter const& f); @@ -531,7 +531,7 @@ namespace libtorrent void load_state(bdecode_node const* e, std::uint32_t flags); bool has_connection(peer_connection* p) const override; - void insert_peer(boost::shared_ptr const& c) override; + void insert_peer(std::shared_ptr const& c) override; proxy_settings proxy() const override; @@ -602,7 +602,7 @@ namespace libtorrent void free_disk_buffer(char* buf) override; disk_buffer_holder allocate_disk_buffer(char const* category) override; disk_buffer_holder allocate_disk_buffer(bool& exceeded - , boost::shared_ptr o + , std::shared_ptr o , char const* category) override; void reclaim_block(block_cache_reference ref) override; @@ -719,7 +719,7 @@ namespace libtorrent peer_class_pool m_classes; - void init(boost::shared_ptr pack); + void init(std::shared_ptr pack); void submit_disk_jobs(); @@ -827,7 +827,7 @@ namespace libtorrent // once a peer is disconnected, it's put in this list and // every second their refcount is checked, and if it's 1, // they are deleted (from the network thread) - std::vector> m_undead_peers; + std::vector> m_undead_peers; // keep the io_service alive until we have posted the job // to clear the undead peers @@ -853,7 +853,7 @@ namespace libtorrent peer_class_type_filter m_peer_class_type_filter; // filters incoming connections - boost::shared_ptr m_ip_filter; + std::shared_ptr m_ip_filter; // filters outgoing connections port_filter m_port_filter; @@ -1173,7 +1173,7 @@ namespace libtorrent // this list of tracker loggers serves as tracker_callbacks when // shutting down. This list is just here to keep them alive during // whe shutting down process - std::list > m_tracker_loggers; + std::list> m_tracker_loggers; #endif // state for keeping track of external IPs diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index bf2c51283..18a95b64b 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/disk_buffer_holder.hpp" #include +#include #ifndef TORRENT_DISABLE_DHT #include "libtorrent/socket.hpp" @@ -49,12 +50,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" -#include - -#ifndef TORRENT_DISABLE_LOGGING -#include -#endif - #ifdef TORRENT_USE_OPENSSL #include #endif @@ -164,7 +159,7 @@ namespace libtorrent { namespace aux , callback_t const& h) = 0; virtual bool has_connection(peer_connection* p) const = 0; - virtual void insert_peer(boost::shared_ptr const& c) = 0; + virtual void insert_peer(std::shared_ptr const& c) = 0; virtual void evict_torrent(torrent* t) = 0; @@ -248,7 +243,7 @@ namespace libtorrent { namespace aux virtual void trigger_auto_manage() = 0; - virtual void apply_settings_pack(boost::shared_ptr pack) = 0; + virtual void apply_settings_pack(std::shared_ptr pack) = 0; virtual session_settings const& settings() const = 0; virtual void queue_tracker_request(tracker_request& req diff --git a/include/libtorrent/bandwidth_manager.hpp b/include/libtorrent/bandwidth_manager.hpp index db10e2b1c..414db80bf 100644 --- a/include/libtorrent/bandwidth_manager.hpp +++ b/include/libtorrent/bandwidth_manager.hpp @@ -33,11 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_BANDWIDTH_MANAGER_HPP_INCLUDED #define TORRENT_BANDWIDTH_MANAGER_HPP_INCLUDED -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" +#include #include "libtorrent/socket.hpp" #include "libtorrent/error_code.hpp" @@ -68,7 +64,7 @@ struct TORRENT_EXTRA_EXPORT bandwidth_manager // this is used by web seeds // returns the number of bytes to assign to the peer, or 0 // if the peer's 'assign_bandwidth' callback will be called later - int request_bandwidth(boost::shared_ptr const& peer + int request_bandwidth(std::shared_ptr const& peer , int blk, int priority, bandwidth_channel** chan, int num_channels); #if TORRENT_USE_INVARIANT_CHECKS diff --git a/include/libtorrent/bandwidth_queue_entry.hpp b/include/libtorrent/bandwidth_queue_entry.hpp index 0c6b7df62..d7c5df994 100644 --- a/include/libtorrent/bandwidth_queue_entry.hpp +++ b/include/libtorrent/bandwidth_queue_entry.hpp @@ -33,9 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_BANDWIDTH_QUEUE_ENTRY_HPP_INCLUDED #define TORRENT_BANDWIDTH_QUEUE_ENTRY_HPP_INCLUDED -#include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include "libtorrent/aux_/disable_warnings_pop.hpp" +#include #include "libtorrent/bandwidth_limit.hpp" #include "libtorrent/bandwidth_socket.hpp" @@ -44,10 +42,10 @@ namespace libtorrent { struct TORRENT_EXTRA_EXPORT bw_request { - bw_request(boost::shared_ptr const& pe + bw_request(std::shared_ptr const& pe , int blk, int prio); - boost::shared_ptr peer; + std::shared_ptr peer; // 1 is normal prio int priority; // the number of bytes assigned to this request so far diff --git a/include/libtorrent/broadcast_socket.hpp b/include/libtorrent/broadcast_socket.hpp index 5a0d58390..b3b471230 100644 --- a/include/libtorrent/broadcast_socket.hpp +++ b/include/libtorrent/broadcast_socket.hpp @@ -39,10 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/address.hpp" #include "libtorrent/error_code.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include "libtorrent/aux_/disable_warnings_pop.hpp" - +#include #include namespace libtorrent @@ -82,12 +79,12 @@ namespace libtorrent struct socket_entry { - socket_entry(boost::shared_ptr const& s) - : socket(s), broadcast(false) { memset(buffer, 0, sizeof(buffer)); } - socket_entry(boost::shared_ptr const& s + socket_entry(std::shared_ptr const& s) + : socket(s), broadcast(false) { std::memset(buffer, 0, sizeof(buffer)); } + socket_entry(std::shared_ptr const& s , address_v4 const& mask): socket(s), netmask(mask), broadcast(false) - { memset(buffer, 0, sizeof(buffer)); } - boost::shared_ptr socket; + { std::memset(buffer, 0, sizeof(buffer)); } + std::shared_ptr socket; char buffer[1500]; udp::endpoint remote; address_v4 netmask; diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 9b87ebbfe..84cbe778c 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -45,6 +45,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" +#include #include #include "libtorrent/aux_/disable_warnings_pop.hpp" diff --git a/include/libtorrent/disk_buffer_holder.hpp b/include/libtorrent/disk_buffer_holder.hpp index d5e083aca..e3510a8c0 100644 --- a/include/libtorrent/disk_buffer_holder.hpp +++ b/include/libtorrent/disk_buffer_holder.hpp @@ -37,11 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/disk_io_job.hpp" // for block_cache_reference -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" +#include namespace libtorrent { @@ -55,7 +51,7 @@ namespace libtorrent virtual void reclaim_block(block_cache_reference ref) = 0; virtual disk_buffer_holder allocate_disk_buffer(char const* category) = 0; virtual disk_buffer_holder allocate_disk_buffer(bool& exceeded - , boost::shared_ptr o + , std::shared_ptr o , char const* category) = 0; protected: ~buffer_allocator_interface() {} diff --git a/include/libtorrent/disk_buffer_pool.hpp b/include/libtorrent/disk_buffer_pool.hpp index e4391e6c8..93d1e76d6 100644 --- a/include/libtorrent/disk_buffer_pool.hpp +++ b/include/libtorrent/disk_buffer_pool.hpp @@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" -#include #include #ifndef TORRENT_DISABLE_POOL_ALLOCATOR @@ -52,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "libtorrent/io_service_fwd.hpp" #include "libtorrent/file.hpp" // for iovec_t @@ -75,7 +75,7 @@ namespace libtorrent #endif char* allocate_buffer(char const* category); - char* allocate_buffer(bool& exceeded, boost::shared_ptr o + char* allocate_buffer(bool& exceeded, std::shared_ptr o , char const* category); void free_buffer(char* buf); void free_multiple_buffers(char** bufvec, int numbufs); @@ -121,7 +121,7 @@ namespace libtorrent // adding up callbacks to this queue. Once the number // of buffers in use drops below the low watermark, // we start calling these functions back - std::vector> m_observers; + std::vector> m_observers; // callback used to tell the cache it needs to free up some blocks std::function m_trigger_cache_trim; diff --git a/include/libtorrent/disk_io_thread.hpp b/include/libtorrent/disk_io_thread.hpp index 183b9212d..6e6bacd9a 100644 --- a/include/libtorrent/disk_io_thread.hpp +++ b/include/libtorrent/disk_io_thread.hpp @@ -53,7 +53,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include #include @@ -64,6 +63,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" +#include + namespace libtorrent { class alert; @@ -357,11 +358,11 @@ namespace libtorrent disk_buffer_holder allocate_disk_buffer(char const* category) override { bool exceed = false; - return allocate_disk_buffer(exceed, boost::shared_ptr(), category); + return allocate_disk_buffer(exceed, std::shared_ptr(), category); } void trigger_cache_trim(); - disk_buffer_holder allocate_disk_buffer(bool& exceeded, boost::shared_ptr o + disk_buffer_holder allocate_disk_buffer(bool& exceeded, std::shared_ptr o , char const* category) override; bool exceeded_cache_use() const diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index b31aa7fe3..b0b693672 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" #include -#include #ifdef TORRENT_WINDOWS // windows part @@ -224,12 +223,12 @@ namespace libtorrent char stack[2048]; private: - boost::shared_ptr m_file; + std::shared_ptr m_file; }; void TORRENT_EXTRA_EXPORT print_open_files(char const* event, char const* name); #else - using file_handle = boost::shared_ptr; + using file_handle = std::shared_ptr; #endif struct TORRENT_EXTRA_EXPORT file: boost::noncopyable @@ -358,4 +357,3 @@ namespace libtorrent } #endif // TORRENT_FILE_HPP_INCLUDED - diff --git a/include/libtorrent/http_connection.hpp b/include/libtorrent/http_connection.hpp index 4773b7f1c..2f8ba3810 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 #ifdef TORRENT_USE_OPENSSL diff --git a/include/libtorrent/http_tracker_connection.hpp b/include/libtorrent/http_tracker_connection.hpp index 6096cd632..739d5c15e 100644 --- a/include/libtorrent/http_tracker_connection.hpp +++ b/include/libtorrent/http_tracker_connection.hpp @@ -35,12 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include - -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" +#include #include "libtorrent/config.hpp" #include "libtorrent/lazy_entry.hpp" diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 483f31569..57aa20257 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -75,8 +75,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include #include #include @@ -273,7 +271,7 @@ namespace libtorrent , public peer_class_set , public disk_observer , public peer_connection_interface - , public boost::enable_shared_from_this + , public std::enable_shared_from_this { friend class invariant_access; friend class torrent; @@ -705,7 +703,7 @@ namespace libtorrent enum sync_t { read_async, read_sync }; void setup_receive(); - boost::shared_ptr self() + std::shared_ptr self() { TORRENT_ASSERT(!m_in_constructor); return shared_from_this(); diff --git a/include/libtorrent/peer_connection_handle.hpp b/include/libtorrent/peer_connection_handle.hpp index 59ec788f8..59912ee8d 100644 --- a/include/libtorrent/peer_connection_handle.hpp +++ b/include/libtorrent/peer_connection_handle.hpp @@ -53,7 +53,7 @@ typedef boost::system::error_code error_code; // hidden struct TORRENT_EXPORT peer_connection_handle { - peer_connection_handle(boost::weak_ptr impl) + peer_connection_handle(std::weak_ptr impl) : m_connection(impl) {} @@ -113,19 +113,26 @@ struct TORRENT_EXPORT peer_connection_handle time_point time_of_last_unchoke() const; bool operator==(peer_connection_handle const& o) const - { return !(m_connection < o.m_connection) && !(o.m_connection < m_connection); } + { return !lt(m_connection, o.m_connection) && !lt(o.m_connection, m_connection); } bool operator!=(peer_connection_handle const& o) const - { return m_connection < o.m_connection || o.m_connection < m_connection; } + { return lt(m_connection, o.m_connection) || lt(o.m_connection, m_connection); } bool operator<(peer_connection_handle const& o) const - { return m_connection < o.m_connection; } + { return lt(m_connection, o.m_connection); } - boost::shared_ptr native_handle() const + std::shared_ptr native_handle() const { return m_connection.lock(); } private: - boost::weak_ptr m_connection; + std::weak_ptr m_connection; + + // copied from boost::weak_ptr + bool lt(std::weak_ptr const& a + , std::weak_ptr const& b) const + { + return a.owner_before(b); + } }; struct TORRENT_EXPORT bt_peer_connection_handle : public peer_connection_handle @@ -142,7 +149,7 @@ struct TORRENT_EXPORT bt_peer_connection_handle : public peer_connection_handle void switch_send_crypto(std::shared_ptr crypto); void switch_recv_crypto(std::shared_ptr crypto); - boost::shared_ptr native_handle() const; + std::shared_ptr native_handle() const; }; } // namespace libtorrent diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index b97d4addf..94a9ddfd2 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -114,13 +114,13 @@ namespace libtorrent session_proxy& operator=(session_proxy const&); private: session_proxy( - boost::shared_ptr ios + std::shared_ptr ios , std::shared_ptr t - , boost::shared_ptr impl); + , std::shared_ptr impl); - boost::shared_ptr m_io_service; + std::shared_ptr m_io_service; std::shared_ptr m_thread; - boost::shared_ptr m_impl; + std::shared_ptr m_impl; }; // The session_params is a parameters pack for configuring the session @@ -337,9 +337,9 @@ namespace libtorrent // data shared between the main thread // and the working thread - boost::shared_ptr m_io_service; + std::shared_ptr m_io_service; std::shared_ptr m_thread; - boost::shared_ptr m_impl; + std::shared_ptr m_impl; }; } diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 3bb230b22..322ec44fa 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -37,10 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/string_view.hpp" #include - -#include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include "libtorrent/aux_/disable_warnings_pop.hpp" +#include // OVERVIEW // @@ -59,7 +56,7 @@ namespace libtorrent struct settings_pack; struct bdecode_node; - TORRENT_EXTRA_EXPORT boost::shared_ptr load_pack_from_dict(bdecode_node const& settings); + TORRENT_EXTRA_EXPORT std::shared_ptr load_pack_from_dict(bdecode_node const& settings); TORRENT_EXTRA_EXPORT void save_settings_to_dict(aux::session_settings const& s, entry::dictionary_type& sett); TORRENT_EXTRA_EXPORT void apply_pack(settings_pack const* pack, aux::session_settings& sett , aux::session_impl* ses = nullptr); @@ -69,7 +66,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE struct session_settings; - boost::shared_ptr load_pack_from_struct(aux::session_settings const& current, session_settings const& s); + std::shared_ptr load_pack_from_struct(aux::session_settings const& current, session_settings const& s); void load_struct_from_settings(aux::session_settings const& current, session_settings& ret); #endif diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 81b8ea118..20145bedd 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -39,12 +39,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/piece_picker.hpp" diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index d5a00610a..06969b1e7 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -41,13 +41,6 @@ POSSIBILITY OF SUCH DAMAGE. #include // for numeric_limits #include // for unique_ptr -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include "libtorrent/torrent_handle.hpp" #include "libtorrent/entry.hpp" #include "libtorrent/torrent_info.hpp" @@ -382,7 +375,7 @@ namespace libtorrent }; void read_piece(int piece); void on_disk_read_complete(disk_io_job const* j, peer_request r - , boost::shared_ptr rp); + , std::shared_ptr rp); storage_mode_t storage_mode() const; storage_interface* get_storage(); @@ -434,7 +427,7 @@ namespace libtorrent void sent_syn(bool ipv6); void received_synack(bool ipv6); - void set_ip_filter(boost::shared_ptr ipf); + void set_ip_filter(std::shared_ptr ipf); void port_filter_updated(); ip_filter const* get_ip_filter() { return m_ip_filter.get(); } @@ -1143,7 +1136,7 @@ namespace libtorrent void need_peer_list(); - boost::shared_ptr m_ip_filter; + std::shared_ptr m_ip_filter; // all time totals of uploaded and downloaded payload // stored in resume data @@ -1170,7 +1163,7 @@ namespace libtorrent std::shared_ptr m_storage; #ifdef TORRENT_USE_OPENSSL - boost::shared_ptr m_ssl_ctx; + std::shared_ptr m_ssl_ctx; bool verify_peer_cert(bool preverified, boost::asio::ssl::verify_context& ctx); diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 545a41f66..2d0f68865 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -38,11 +38,9 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include - #ifndef TORRENT_NO_DEPRECATE // for deprecated force_reannounce #include diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index f9190946e..1cf4c4fe6 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -42,12 +42,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include -#include #include #ifdef TORRENT_USE_OPENSSL @@ -136,7 +134,7 @@ namespace libtorrent std::string auth; #endif - boost::shared_ptr filter; + std::shared_ptr filter; std::int64_t downloaded; std::int64_t uploaded; @@ -299,7 +297,7 @@ namespace libtorrent , io_service& ios , std::weak_ptr r); - void update_transaction_id(boost::shared_ptr c + void update_transaction_id(std::shared_ptr c , std::uint64_t tid); std::shared_ptr requester() const; diff --git a/include/libtorrent/udp_tracker_connection.hpp b/include/libtorrent/udp_tracker_connection.hpp index 58fe0702e..895ae6b15 100644 --- a/include/libtorrent/udp_tracker_connection.hpp +++ b/include/libtorrent/udp_tracker_connection.hpp @@ -39,10 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include - -#include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include "libtorrent/aux_/disable_warnings_pop.hpp" +#include #include "libtorrent/udp_socket.hpp" #include "libtorrent/entry.hpp" diff --git a/include/libtorrent/upnp.hpp b/include/libtorrent/upnp.hpp index f7c26b6f5..a21985946 100644 --- a/include/libtorrent/upnp.hpp +++ b/include/libtorrent/upnp.hpp @@ -42,10 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/resolver.hpp" #include "libtorrent/debug.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include "libtorrent/aux_/disable_warnings_pop.hpp" - +#include #include #include diff --git a/simulation/setup_dht.cpp b/simulation/setup_dht.cpp index 0fc62106c..b56fcf380 100644 --- a/simulation/setup_dht.cpp +++ b/simulation/setup_dht.cpp @@ -254,7 +254,7 @@ struct dht_node final : lt::dht::udp_socket_interface private: asio::io_service m_io_service; - boost::shared_ptr m_dht_storage; + std::shared_ptr m_dht_storage; #if LIBSIMULATOR_USE_MOVE lt::udp::socket m_socket; lt::udp::socket& sock() { return m_socket; } diff --git a/simulation/setup_swarm.cpp b/simulation/setup_swarm.cpp index 065b5663a..d5525de27 100644 --- a/simulation/setup_swarm.cpp +++ b/simulation/setup_swarm.cpp @@ -260,8 +260,8 @@ void setup_swarm(int num_nodes asio::io_service ios(sim); lt::time_point start_time(lt::clock_type::now()); - std::vector > nodes; - std::vector > io_service; + std::vector> nodes; + std::vector> io_service; std::vector zombies; lt::deadline_timer timer(ios); @@ -286,8 +286,7 @@ void setup_swarm(int num_nodes ips.push_back(addr(ep)); 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( - std::ref(sim), ips)); + io_service.push_back(std::make_shared(sim, ips)); lt::settings_pack pack = default_settings; @@ -297,9 +296,8 @@ void setup_swarm(int num_nodes pack.set_str(lt::settings_pack::peer_fingerprint, pid.to_string()); if (i == 0) new_session(pack); - boost::shared_ptr ses = - boost::make_shared(pack - , std::ref(*io_service.back())); + std::shared_ptr ses = + std::make_shared(pack, *io_service.back()); init_session(*ses); nodes.push_back(ses); @@ -396,7 +394,7 @@ void setup_swarm(int num_nodes if (type == swarm_test::upload) { shut_down |= std::all_of(nodes.begin() + 1, nodes.end() - , [](boost::shared_ptr const& s) + , [](std::shared_ptr const& s) { return is_seed(*s); }); if (tick > 88 * (num_nodes - 1) && !shut_down) diff --git a/simulation/test_dht_bootstrap.cpp b/simulation/test_dht_bootstrap.cpp index a56b33731..dd69d940e 100644 --- a/simulation/test_dht_bootstrap.cpp +++ b/simulation/test_dht_bootstrap.cpp @@ -78,7 +78,7 @@ TORRENT_TEST(dht_bootstrap) pack.set_bool(lt::settings_pack::enable_natpmp, false); pack.set_bool(lt::settings_pack::enable_dht, true); sim::asio::io_service ios(sim, addr("10.0.0.1")); - boost::shared_ptr ses = boost::make_shared(pack, ios); + std::shared_ptr ses = std::make_shared(pack, ios); lt::deadline_timer timer(ios); timer.expires_from_now(lt::seconds(10)); diff --git a/simulation/test_dht_rate_limit.cpp b/simulation/test_dht_rate_limit.cpp index d9e97ef55..4be8f9579 100644 --- a/simulation/test_dht_rate_limit.cpp +++ b/simulation/test_dht_rate_limit.cpp @@ -110,8 +110,8 @@ TORRENT_TEST(dht_rate_limit) counters cnt; entry state; std::unique_ptr dht_storage(dht::dht_default_storage_constructor(dhtsett)); - boost::shared_ptr dht = boost::make_shared( - &o, std::ref(dht_ios), std::bind(&udp_socket::send, &sock, _1, _2, _3, _4) + std::shared_ptr dht = std::make_shared( + &o, 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_optimistic_unchoke.cpp b/simulation/test_optimistic_unchoke.cpp index 76502c961..3a0d47035 100644 --- a/simulation/test_optimistic_unchoke.cpp +++ b/simulation/test_optimistic_unchoke.cpp @@ -47,10 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_info.hpp" #include "libtorrent/deadline_timer.hpp" -#include -#include -#include -#include +#include struct choke_state { diff --git a/simulation/test_save_resume.cpp b/simulation/test_save_resume.cpp index 2be385b23..f0d87968c 100644 --- a/simulation/test_save_resume.cpp +++ b/simulation/test_save_resume.cpp @@ -41,7 +41,7 @@ using namespace libtorrent; TORRENT_TEST(seed_and_suggest_mode) { - boost::shared_ptr resume_data; + std::shared_ptr resume_data; // with seed mode setup_swarm(2, swarm_test::upload diff --git a/src/alert.cpp b/src/alert.cpp index f33cc99e7..a88c8bfeb 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -739,7 +739,7 @@ namespace libtorrent { } save_resume_data_alert::save_resume_data_alert(aux::stack_allocator& alloc - , boost::shared_ptr const& rd + , std::shared_ptr const& rd , torrent_handle const& h) : torrent_alert(alloc, h) , resume_data(rd) diff --git a/src/bandwidth_manager.cpp b/src/bandwidth_manager.cpp index 8be3e6b19..6622d8c73 100644 --- a/src/bandwidth_manager.cpp +++ b/src/bandwidth_manager.cpp @@ -84,7 +84,7 @@ namespace libtorrent // non prioritized means that, if there's a line for bandwidth, // others will cut in front of the non-prioritized peers. // this is used by web seeds - int bandwidth_manager::request_bandwidth(boost::shared_ptr const& peer + int bandwidth_manager::request_bandwidth(std::shared_ptr const& peer , int blk, int priority, bandwidth_channel** chan, int num_channels) { INVARIANT_CHECK; diff --git a/src/bandwidth_queue_entry.cpp b/src/bandwidth_queue_entry.cpp index 84075e3e0..5213577cf 100644 --- a/src/bandwidth_queue_entry.cpp +++ b/src/bandwidth_queue_entry.cpp @@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - bw_request::bw_request(boost::shared_ptr const& pe + bw_request::bw_request(std::shared_ptr const& pe , int blk, int prio) : peer(pe) , priority(prio) diff --git a/src/broadcast_socket.cpp b/src/broadcast_socket.cpp index 196cb89c7..88a399c92 100644 --- a/src/broadcast_socket.cpp +++ b/src/broadcast_socket.cpp @@ -213,7 +213,7 @@ namespace libtorrent { using namespace boost::asio::ip::multicast; - boost::shared_ptr s(new udp::socket(ios)); + std::shared_ptr s = std::make_shared(ios); s->open(addr.is_v4() ? udp::v4() : udp::v6(), ec); if (ec) return; s->set_option(udp::socket::reuse_address(true), ec); @@ -238,7 +238,7 @@ namespace libtorrent , address_v4 const& mask) { error_code ec; - boost::shared_ptr s(new udp::socket(ios)); + std::shared_ptr s = std::make_shared(ios); s->open(addr.is_v4() ? udp::v4() : udp::v6(), ec); if (ec) return; s->bind(udp::endpoint(addr, 0), ec); diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index cceb8854a..1aefd0b5f 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -73,8 +73,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hasher.hpp" #endif -using boost::shared_ptr; - namespace libtorrent { namespace mp = boost::multiprecision; diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index 8f50d1a57..ffda649b9 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -42,13 +42,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/performance_counters.hpp" // for counters #include "libtorrent/alert_manager.hpp" -#include -#include - #include #include #include +#include using namespace std::placeholders; diff --git a/src/disk_buffer_pool.cpp b/src/disk_buffer_pool.cpp index d042ba4fc..6279b55f2 100644 --- a/src/disk_buffer_pool.cpp +++ b/src/disk_buffer_pool.cpp @@ -60,11 +60,11 @@ namespace libtorrent namespace { // this is posted to the network thread - void watermark_callback(std::vector> const& cbs) + void watermark_callback(std::vector> const& cbs) { for (auto const& i : cbs) { - boost::shared_ptr o = i.lock(); + std::shared_ptr o = i.lock(); if (o) o->on_disk(); } } @@ -148,7 +148,7 @@ namespace libtorrent m_exceeded_max_size = false; - std::vector> cbs; + std::vector> cbs; m_observers.swap(cbs); l.unlock(); m_ios.post(std::bind(&watermark_callback, std::move(cbs))); @@ -205,7 +205,7 @@ namespace libtorrent // that there's more room in the pool now. This caps the amount of over- // allocation to one block per peer connection. char* disk_buffer_pool::allocate_buffer(bool& exceeded - , boost::shared_ptr o, char const* category) + , std::shared_ptr o, char const* category) { std::unique_lock l(m_pool_mutex); char* ret = allocate_buffer_impl(l, category); diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 161f31d4f..53dd89194 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -3353,7 +3353,7 @@ namespace libtorrent } disk_buffer_holder disk_io_thread::allocate_disk_buffer(bool& exceeded - , boost::shared_ptr o + , std::shared_ptr o , char const* category) { char* ret = m_disk_cache.allocate_buffer(exceeded, o, category); diff --git a/src/file_pool.cpp b/src/file_pool.cpp index 918ffedca..7167554a3 100644 --- a/src/file_pool.cpp +++ b/src/file_pool.cpp @@ -171,7 +171,7 @@ namespace libtorrent // file, we can only delete our reference to it. // if this is the only reference to the file, it will be closed defer_destruction = e.file_ptr; - e.file_ptr = boost::make_shared(); + e.file_ptr = std::make_shared(); std::string full_path = fs.file_path(file_index, p); if (!e.file_ptr->open(full_path, m, ec)) @@ -191,7 +191,7 @@ namespace libtorrent } lru_file_entry e; - e.file_ptr = boost::make_shared(); + e.file_ptr = std::make_shared(); if (!e.file_ptr) { ec = error_code(boost::system::errc::not_enough_memory, generic_category()); diff --git a/src/http_seed_connection.cpp b/src/http_seed_connection.cpp index 881d92dc0..e22d7c94d 100644 --- a/src/http_seed_connection.cpp +++ b/src/http_seed_connection.cpp @@ -39,8 +39,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_info.hpp" #include "libtorrent/hex.hpp" // for is_hex -using boost::shared_ptr; - namespace libtorrent { http_seed_connection::http_seed_connection(peer_connection_args const& pack diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index f4134dd91..7bda8f5f9 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -80,7 +80,6 @@ POSSIBILITY OF SUCH DAMAGE. //#define TORRENT_CORRUPT_DATA -using boost::shared_ptr; using namespace std::placeholders; namespace libtorrent @@ -1376,7 +1375,7 @@ namespace libtorrent std::vector::iterator dlq_iter = std::find_if( m_download_queue.begin(), m_download_queue.end() - , std::bind(match_request, boost::cref(r), std::bind(&pending_block::block, _1) + , std::bind(match_request, std::cref(r), std::bind(&pending_block::block, _1) , t->block_size())); if (dlq_iter != m_download_queue.end()) @@ -4111,7 +4110,7 @@ namespace libtorrent #endif // TORRENT_DISABLE_ENCRYPTION } - boost::shared_ptr me(self()); + std::shared_ptr me(self()); INVARIANT_CHECK; @@ -4530,7 +4529,7 @@ namespace libtorrent { TORRENT_ASSERT(is_single_thread()); time_point now = aux::time_now(); - boost::shared_ptr me(self()); + std::shared_ptr me(self()); // the invariant check must be run before me is destructed // in case the peer got disconnected @@ -5515,7 +5514,7 @@ namespace libtorrent { TORRENT_ASSERT(is_single_thread()); if ((m_channel_state[download_channel] & peer_info::bw_disk) == 0) return; - boost::shared_ptr me(self()); + std::shared_ptr me(self()); #ifndef TORRENT_DISABLE_LOGGING peer_log(peer_log_alert::info, "DISK", "dropped below disk buffer watermark"); @@ -5739,7 +5738,7 @@ namespace libtorrent // case we disconnect // this needs to be created before the invariant check, // to keep the object alive through the exit check - boost::shared_ptr me(self()); + std::shared_ptr me(self()); // flush the send buffer at the end of this function cork _c(*this); @@ -6074,7 +6073,7 @@ namespace libtorrent COMPLETE_ASYNC("peer_connection::on_send_data"); // keep ourselves alive in until this function exits in // case we disconnect - boost::shared_ptr me(self()); + std::shared_ptr me(self()); TORRENT_ASSERT(m_channel_state[upload_channel] & peer_info::bw_network); diff --git a/src/peer_connection_handle.cpp b/src/peer_connection_handle.cpp index 26fbae8a6..29692e075 100644 --- a/src/peer_connection_handle.cpp +++ b/src/peer_connection_handle.cpp @@ -43,7 +43,7 @@ namespace libtorrent int peer_connection_handle::type() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->type(); } @@ -51,7 +51,7 @@ int peer_connection_handle::type() const void peer_connection_handle::add_extension(std::shared_ptr ext) { #ifndef TORRENT_DISABLE_EXTENSIONS - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->add_extension(ext); #else @@ -61,84 +61,84 @@ void peer_connection_handle::add_extension(std::shared_ptr ext) bool peer_connection_handle::is_seed() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->is_seed(); } bool peer_connection_handle::upload_only() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->upload_only(); } peer_id const& peer_connection_handle::pid() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->pid(); } bool peer_connection_handle::has_piece(int i) const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->has_piece(i); } bool peer_connection_handle::is_interesting() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->is_interesting(); } bool peer_connection_handle::is_choked() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->is_choked(); } bool peer_connection_handle::is_peer_interested() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->is_peer_interested(); } bool peer_connection_handle::has_peer_choked() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->has_peer_choked(); } void peer_connection_handle::choke_this_peer() { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->choke_this_peer(); } void peer_connection_handle::maybe_unchoke_this_peer() { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->maybe_unchoke_this_peer(); } void peer_connection_handle::get_peer_info(peer_info& p) const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->get_peer_info(p); } torrent_handle peer_connection_handle::associated_torrent() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); if (!pc) return torrent_handle(); std::shared_ptr t = pc->associated_torrent().lock(); if (!t) return torrent_handle(); @@ -147,63 +147,63 @@ torrent_handle peer_connection_handle::associated_torrent() const tcp::endpoint const& peer_connection_handle::remote() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->remote(); } tcp::endpoint peer_connection_handle::local_endpoint() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->local_endpoint(); } void peer_connection_handle::disconnect(error_code const& ec, operation_t op, int error) { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->disconnect(ec, op, error); } bool peer_connection_handle::is_disconnecting() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->is_disconnecting(); } bool peer_connection_handle::is_connecting() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->is_connecting(); } bool peer_connection_handle::is_outgoing() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->is_outgoing(); } bool peer_connection_handle::on_local_network() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->on_local_network(); } bool peer_connection_handle::ignore_unchoke_slots() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->ignore_unchoke_slots(); } bool peer_connection_handle::failed() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->failed(); } @@ -214,7 +214,7 @@ TORRENT_FORMAT(4,5) void peer_connection_handle::peer_log(peer_log_alert::direction_t direction , char const* event, char const* fmt, ...) const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); va_list v; va_start(v, fmt); @@ -234,56 +234,56 @@ void peer_connection_handle::peer_log(peer_log_alert::direction_t direction bool peer_connection_handle::can_disconnect(error_code const& ec) const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->can_disconnect(ec); } bool peer_connection_handle::has_metadata() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->has_metadata(); } bool peer_connection_handle::in_handshake() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->in_handshake(); } void peer_connection_handle::send_buffer(char const* begin, int size, int flags) { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->send_buffer(begin, size, flags); } time_t peer_connection_handle::last_seen_complete() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->last_seen_complete(); } time_point peer_connection_handle::time_of_last_unchoke() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->time_of_last_unchoke(); } bool bt_peer_connection_handle::packet_finished() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->packet_finished(); } bool bt_peer_connection_handle::support_extensions() const { - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->support_extensions(); } @@ -291,7 +291,7 @@ bool bt_peer_connection_handle::support_extensions() const bool bt_peer_connection_handle::supports_encryption() const { #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); return pc->supports_encryption(); #else @@ -302,7 +302,7 @@ bool bt_peer_connection_handle::supports_encryption() const void bt_peer_connection_handle::switch_send_crypto(std::shared_ptr crypto) { #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->switch_send_crypto(crypto); #else @@ -313,7 +313,7 @@ void bt_peer_connection_handle::switch_send_crypto(std::shared_ptr crypto) { #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS) - boost::shared_ptr pc = native_handle(); + std::shared_ptr pc = native_handle(); TORRENT_ASSERT(pc); pc->switch_recv_crypto(crypto); #else @@ -321,9 +321,9 @@ void bt_peer_connection_handle::switch_recv_crypto(std::shared_ptr bt_peer_connection_handle::native_handle() const +std::shared_ptr bt_peer_connection_handle::native_handle() const { - return boost::static_pointer_cast( + return std::static_pointer_cast( peer_connection_handle::native_handle()); } diff --git a/src/peer_list.cpp b/src/peer_list.cpp index 39cf74cd4..13b431223 100644 --- a/src/peer_list.cpp +++ b/src/peer_list.cpp @@ -30,12 +30,6 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include #include "libtorrent/peer_connection.hpp" @@ -53,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/extensions.hpp" #include "libtorrent/ip_filter.hpp" #include "libtorrent/torrent_peer_allocator.hpp" +#include "libtorrent/ip_voter.hpp" // for external_ip #if TORRENT_USE_ASSERTS #include "libtorrent/socket_io.hpp" // for print_endpoint @@ -60,7 +55,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/socket_io.hpp" // for print_endpoint -#include "libtorrent/ip_voter.hpp" // for external_ip #endif using namespace std::placeholders; @@ -550,7 +544,7 @@ namespace libtorrent // insert this candidate sorted into peers std::vector::iterator i = std::lower_bound(peers.begin(), peers.end() - , &pe, std::bind(&peer_list::compare_peer, this, _1, _2, boost::cref(external), external_port)); + , &pe, std::bind(&peer_list::compare_peer, this, _1, _2, std::cref(external), external_port)); peers.insert(i, &pe); } diff --git a/src/session.cpp b/src/session.cpp index 11e978178..1b0deb8c0 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -296,11 +296,11 @@ namespace libtorrent if (internal_executor) { // the user did not provide an executor, we have to use our own - m_io_service = boost::make_shared(); + m_io_service = std::make_shared(); ios = m_io_service.get(); } - m_impl = boost::make_shared(std::ref(*ios)); + m_impl = std::make_shared(*ios); *static_cast(this) = session_handle(m_impl.get()); #ifndef TORRENT_DISABLE_EXTENSIONS @@ -354,7 +354,7 @@ namespace libtorrent aux::dump_call_profile(); TORRENT_ASSERT(m_impl); - boost::shared_ptr ptr = m_impl; + std::shared_ptr ptr = m_impl; // capture the shared_ptr in the dispatched function // to keep the session_impl alive @@ -399,9 +399,9 @@ namespace libtorrent #endif // TORRENT_NO_DEPRECATE session_proxy::session_proxy() = default; - session_proxy::session_proxy(boost::shared_ptr ios + session_proxy::session_proxy(std::shared_ptr ios , std::shared_ptr t - , boost::shared_ptr impl) + , std::shared_ptr impl) : m_io_service(std::move(ios)) , m_thread(std::move(t)) , m_impl(impl) diff --git a/src/session_handle.cpp b/src/session_handle.cpp index 5b4c884b6..63ba80394 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -680,7 +680,7 @@ namespace libtorrent void session_handle::set_ip_filter(ip_filter const& f) { - boost::shared_ptr copy = boost::make_shared(f); + std::shared_ptr copy = std::make_shared(f); async_call(&session_impl::set_ip_filter, copy); } @@ -844,7 +844,7 @@ namespace libtorrent || s.get_int(settings_pack::allowed_enc_level) <= settings_pack::pe_both); - boost::shared_ptr copy = boost::make_shared(std::move(s)); + std::shared_ptr copy = std::make_shared(std::move(s)); async_call(&session_impl::apply_settings_pack, copy); } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index fe7c9cbb4..0a966cbf4 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -47,7 +47,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" #include -#include #include #if TORRENT_USE_RLIMIT @@ -169,8 +168,6 @@ namespace #include #endif -using boost::shared_ptr; -using boost::weak_ptr; using libtorrent::aux::session_impl; using namespace std::placeholders; @@ -430,11 +427,11 @@ namespace aux { session_log(" generated peer ID: %s", m_peer_id.to_string().c_str()); #endif - boost::shared_ptr copy = boost::make_shared(pack); + std::shared_ptr copy = std::make_shared(pack); m_io_service.post(std::bind(&session_impl::init, this, copy)); } - void session_impl::init(boost::shared_ptr pack) + void session_impl::init(std::shared_ptr pack) { // this is a debug facility // see single_threaded in debug.hpp @@ -695,7 +692,7 @@ namespace aux { if (settings) { // apply_settings_pack will update dht and proxy - boost::shared_ptr pack = load_pack_from_dict(settings); + std::shared_ptr pack = load_pack_from_dict(settings); apply_settings_pack(pack); #ifndef TORRENT_DISABLE_DHT need_update_dht = false; @@ -918,7 +915,7 @@ namespace aux { return m_connections.find(p->self()) != m_connections.end(); } - void session_impl::insert_peer(boost::shared_ptr const& c) + void session_impl::insert_peer(std::shared_ptr const& c) { TORRENT_ASSERT(!c->m_in_constructor); m_connections.insert(c); @@ -936,7 +933,7 @@ namespace aux { i->second->port_filter_updated(); } - void session_impl::set_ip_filter(boost::shared_ptr const& f) + void session_impl::set_ip_filter(std::shared_ptr const& f) { INVARIANT_CHECK; @@ -952,7 +949,7 @@ namespace aux { void session_impl::ban_ip(address addr) { TORRENT_ASSERT(is_single_thread()); - if (!m_ip_filter) m_ip_filter = boost::make_shared(); + if (!m_ip_filter) m_ip_filter = std::make_shared(); m_ip_filter->add_rule(addr, addr, ip_filter::blocked); for (torrent_map::iterator i = m_torrents.begin() , end(m_torrents.end()); i != end; ++i) @@ -962,7 +959,7 @@ namespace aux { ip_filter const& session_impl::get_ip_filter() { TORRENT_ASSERT(is_single_thread()); - if (!m_ip_filter) m_ip_filter = boost::make_shared(); + if (!m_ip_filter) m_ip_filter = std::make_shared(); return *m_ip_filter; } @@ -1369,7 +1366,7 @@ namespace aux { } // session_impl is responsible for deleting 'pack' - void session_impl::apply_settings_pack(boost::shared_ptr pack) + void session_impl::apply_settings_pack(std::shared_ptr pack) { apply_settings_pack_impl(*pack); } @@ -1427,7 +1424,7 @@ namespace aux { { INVARIANT_CHECK; TORRENT_ASSERT(is_single_thread()); - boost::shared_ptr p = load_pack_from_struct(m_settings, s); + std::shared_ptr p = load_pack_from_struct(m_settings, s); apply_settings_pack(p); } @@ -2768,9 +2765,8 @@ namespace aux { pack.endp = endp; pack.peerinfo = nullptr; - boost::shared_ptr c - = boost::make_shared(boost::cref(pack) - , get_peer_id()); + std::shared_ptr c + = std::make_shared(pack, get_peer_id()); #if TORRENT_USE_ASSERTS c->m_in_constructor = false; #endif @@ -2803,7 +2799,7 @@ namespace aux { , error_code const& ec) { TORRENT_ASSERT(is_single_thread()); - boost::shared_ptr sp(p->self()); + std::shared_ptr sp(p->self()); // someone else is holding a reference, it's important that // it's destructed from the network thread. Make sure the @@ -2903,7 +2899,7 @@ namespace aux { { TORRENT_ASSERT(is_single_thread()); return std::any_of(m_connections.begin(), m_connections.end() - , [p] (boost::shared_ptr const& pr) + , [p] (std::shared_ptr const& pr) { return pr.get() == p; }); } @@ -2966,9 +2962,9 @@ namespace aux { // remove undead peers that only have this list as their reference keeping them alive if (!m_undead_peers.empty()) { - std::vector >::iterator remove_it + std::vector >::iterator remove_it = std::remove_if(m_undead_peers.begin(), m_undead_peers.end() - , std::bind(&boost::shared_ptr::unique, _1)); + , std::bind(&std::shared_ptr::unique, _1)); m_undead_peers.erase(remove_it, m_undead_peers.end()); if (m_undead_peers.empty()) { @@ -3681,11 +3677,11 @@ namespace aux { struct opt_unchoke_candidate { - explicit opt_unchoke_candidate(boost::shared_ptr const* tp) + explicit opt_unchoke_candidate(std::shared_ptr const* tp) : peer(tp) {} - boost::shared_ptr const* peer; + std::shared_ptr const* peer; #ifndef TORRENT_DISABLE_EXTENSIONS // this is mutable because comparison functors passed to std::partial_sort // are not supposed to modify the elements they are sorting. Here the mutation @@ -4035,7 +4031,7 @@ namespace aux { for (connection_map::iterator i = m_connections.begin(); i != m_connections.end();) { - boost::shared_ptr p = *i; + std::shared_ptr p = *i; TORRENT_ASSERT(p); ++i; torrent* const t = p->associated_torrent().lock().get(); @@ -4832,9 +4828,9 @@ namespace aux { int queue_pos = ++m_max_queue_pos; - torrent_ptr = std::make_shared(std::ref(*this) + torrent_ptr = std::make_shared(*this , 16 * 1024, queue_pos, m_paused - , boost::cref(params), boost::cref(params.info_hash)); + , params, params.info_hash); return std::make_pair(torrent_ptr, true); } @@ -6649,7 +6645,7 @@ namespace aux { } disk_buffer_holder session_impl::allocate_disk_buffer(bool& exceeded - , boost::shared_ptr o + , std::shared_ptr o , char const* category) { return m_disk_thread.allocate_disk_buffer(exceeded, o, category); @@ -6794,7 +6790,7 @@ namespace aux { } } - for (std::vector >::const_iterator i + for (std::vector >::const_iterator i = m_undead_peers.begin(); i != m_undead_peers.end(); ++i) { peer_connection* p = i->get(); diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index c73d443b2..53ed62563 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -388,9 +388,9 @@ namespace libtorrent return ""; } - boost::shared_ptr load_pack_from_dict(bdecode_node const& settings) + std::shared_ptr load_pack_from_dict(bdecode_node const& settings) { - boost::shared_ptr pack = boost::make_shared(); + std::shared_ptr pack = std::make_shared(); for (int i = 0; i < settings.dict_size(); ++i) { @@ -463,10 +463,10 @@ namespace libtorrent #include "libtorrent/aux_/disable_warnings_push.hpp" - boost::shared_ptr load_pack_from_struct( + std::shared_ptr load_pack_from_struct( aux::session_settings const& current, session_settings const& s) { - boost::shared_ptr p = boost::make_shared(); + std::shared_ptr p = std::make_shared(); for (int i = 0; i < settings_pack::num_string_settings; ++i) { diff --git a/src/torrent.cpp b/src/torrent.cpp index 12ba3c954..e37182117 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -46,8 +46,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" -#include - #ifdef TORRENT_USE_OPENSSL #include "libtorrent/ssl_stream.hpp" #include @@ -774,7 +772,7 @@ namespace libtorrent state_updated(); } - void torrent::set_ip_filter(boost::shared_ptr ipf) + void torrent::set_ip_filter(std::shared_ptr ipf) { m_ip_filter = ipf; if (!m_apply_ip_filter) return; @@ -883,7 +881,7 @@ namespace libtorrent return; } - boost::shared_ptr rp = boost::make_shared(); + std::shared_ptr rp = std::make_shared(); rp->piece_data.reset(new (std::nothrow) char[piece_size]); rp->blocks_left = 0; rp->fail = false; @@ -938,7 +936,7 @@ namespace libtorrent bt_peer_connection* p = static_cast(*i); if (p->type() == peer_connection::bittorrent_connection) { - boost::shared_ptr me(p->self()); + std::shared_ptr me(p->self()); if (!p->is_disconnecting()) { p->send_not_interested(); @@ -1163,7 +1161,7 @@ namespace libtorrent } void torrent::on_disk_read_complete(disk_io_job const* j, peer_request r - , boost::shared_ptr rp) + , std::shared_ptr rp) { // hold a reference until this function returns torrent_ref_holder h(this, "read_piece"); @@ -1557,7 +1555,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(std::ref(m_ses.get_io_service()), context::sslv23); + std::shared_ptr ctx = std::make_shared(m_ses.get_io_service(), context::sslv23); if (!ctx) { @@ -2661,7 +2659,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE void torrent::use_interface(std::string net_interfaces) { - boost::shared_ptr p = boost::make_shared(); + std::shared_ptr p = std::make_shared(); p->set_str(settings_pack::outgoing_interfaces, net_interfaces); m_ses.apply_settings_pack(p); } @@ -4031,7 +4029,7 @@ namespace libtorrent for (peer_iterator i = peers.begin(); i != peers.end(); ++i) { - boost::shared_ptr p = (*i)->self(); + std::shared_ptr p = (*i)->self(); // received_piece will check to see if we're still interested // in this peer, and if neither of us is interested in the other, @@ -6180,7 +6178,7 @@ namespace libtorrent return; } - boost::shared_ptr c; + std::shared_ptr c; peer_connection_args pack; pack.ses = &m_ses; pack.sett = &settings(); @@ -6194,13 +6192,11 @@ namespace libtorrent pack.peerinfo = &web->peer_info; if (web->type == web_seed_entry::url_seed) { - c = boost::make_shared( - boost::cref(pack), std::ref(*web)); + c = std::make_shared(pack, *web); } else if (web->type == web_seed_entry::http_seed) { - c = boost::make_shared( - boost::cref(pack), std::ref(*web)); + c = std::make_shared(pack, *web); } if (!c) return; @@ -6892,8 +6888,8 @@ namespace libtorrent pack.endp = a; pack.peerinfo = peerinfo; - boost::shared_ptr c = boost::make_shared( - boost::cref(pack), m_ses.get_peer_id()); + std::shared_ptr c = std::make_shared( + pack, m_ses.get_peer_id()); TORRENT_TRY { @@ -8737,7 +8733,7 @@ namespace libtorrent state_updated(); - boost::shared_ptr rd(new entry); + std::shared_ptr rd(new entry); write_resume_data(*rd); alerts().emplace_alert(rd, get_handle()); } @@ -9388,7 +9384,7 @@ namespace libtorrent { // keep the peer object alive while we're // inspecting it - boost::shared_ptr p = (*i)->self(); + std::shared_ptr p = (*i)->self(); ++i; // look for the peer that saw a seed most recently diff --git a/src/tracker_manager.cpp b/src/tracker_manager.cpp index 9c1cf1ac1..04cb352db 100644 --- a/src/tracker_manager.cpp +++ b/src/tracker_manager.cpp @@ -30,16 +30,10 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include "libtorrent/aux_/disable_warnings_push.hpp" - #include #include #include - #include -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/tracker_manager.hpp" #include "libtorrent/http_tracker_connection.hpp" diff --git a/src/web_connection_base.cpp b/src/web_connection_base.cpp index 654762f64..c8b86576b 100644 --- a/src/web_connection_base.cpp +++ b/src/web_connection_base.cpp @@ -40,8 +40,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/parse_url.hpp" #include "libtorrent/peer_info.hpp" -using boost::shared_ptr; - namespace libtorrent { web_connection_base::web_connection_base( diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index d8a7e775a..c9e18a13b 100644 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -59,8 +59,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/escape_string.hpp" // for escape_path #include "libtorrent/hex.hpp" // for is_hex -using boost::shared_ptr; - namespace libtorrent { enum @@ -426,7 +424,7 @@ void web_peer_connection::write_request(peer_request const& r) { get_io_service().post(std::bind( &web_peer_connection::on_receive_padfile, - boost::static_pointer_cast(self()))); + std::static_pointer_cast(self()))); return; } diff --git a/test/dht_server.cpp b/test/dht_server.cpp index f74e873c0..7d75d3128 100644 --- a/test/dht_server.cpp +++ b/test/dht_server.cpp @@ -41,8 +41,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "test_utils.hpp" #include -#include -#include #if TORRENT_USE_IOSTREAM #include @@ -50,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include using namespace libtorrent; using namespace std::placeholders; @@ -62,7 +61,7 @@ struct dht_server udp::socket m_socket; int m_port; - boost::shared_ptr m_thread; + std::shared_ptr m_thread; dht_server() : m_dht_requests(0) @@ -92,7 +91,7 @@ struct dht_server std::fprintf(stderr, "%s: DHT initialized on port %d\n", time_now_string(), m_port); - m_thread = boost::make_shared(&dht_server::thread_fun, this); + m_thread = std::make_shared(&dht_server::thread_fun, this); } ~dht_server() @@ -158,7 +157,7 @@ struct dht_server } }; -boost::shared_ptr g_dht; +std::shared_ptr g_dht; int start_dht() { diff --git a/test/peer_server.cpp b/test/peer_server.cpp index b0a918c66..63aff5c3d 100644 --- a/test/peer_server.cpp +++ b/test/peer_server.cpp @@ -42,12 +42,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "test_utils.hpp" #include -#include -#include #include #include #include +#include using namespace libtorrent; using namespace std::placeholders; @@ -148,7 +147,7 @@ struct peer_server } }; -boost::shared_ptr g_peer; +std::shared_ptr g_peer; int start_peer() { diff --git a/test/test_bandwidth_limiter.cpp b/test/test_bandwidth_limiter.cpp index 635063353..3d50b3222 100644 --- a/test/test_bandwidth_limiter.cpp +++ b/test/test_bandwidth_limiter.cpp @@ -41,10 +41,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/time.hpp" #include "libtorrent/aux_/session_settings.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include "libtorrent/aux_/disable_warnings_pop.hpp" - #include #include #include @@ -62,7 +58,7 @@ const float sample_time = 20.f; // seconds bandwidth_channel global_bwc; -struct peer_connection: bandwidth_socket, boost::enable_shared_from_this +struct peer_connection: bandwidth_socket, std::enable_shared_from_this { peer_connection(bandwidth_manager& bwm , bandwidth_channel& torrent_bwc, int prio, bool ignore_limits, std::string name) @@ -116,7 +112,7 @@ void peer_connection::start() } -typedef std::vector> connections_t; +typedef std::vector> connections_t; void do_change_rate(bandwidth_channel& t1, bandwidth_channel& t2, int limit) { @@ -183,7 +179,7 @@ void spawn_connections(connections_t& v, bandwidth_manager& bwm { char name[200]; std::snprintf(name, sizeof(name), "%s%d", prefix, i); - v.push_back(boost::make_shared(bwm, bwc, 200, false, name)); + v.push_back(std::make_shared(bwm, bwc, 200, false, name)); } } @@ -403,8 +399,8 @@ void test_peer_priority(int limit, bool torrent_limit) spawn_connections(v1, manager, t1, 10, "p"); connections_t v; std::copy(v1.begin(), v1.end(), std::back_inserter(v)); - boost::shared_ptr p = - boost::make_shared(manager, t1, 1, false, "no-priority"); + std::shared_ptr p = + std::make_shared(manager, t1, 1, false, "no-priority"); v.push_back(p); run_test(v, manager); @@ -439,8 +435,8 @@ void test_no_starvation(int limit) spawn_connections(v1, manager, t1, num_peers, "p"); connections_t v; std::copy(v1.begin(), v1.end(), std::back_inserter(v)); - boost::shared_ptr p = - boost::make_shared(manager, t2, 1, false, "no-priority"); + std::shared_ptr p = + std::make_shared(manager, t2, 1, false, "no-priority"); v.push_back(p); run_test(v, manager); diff --git a/test/test_block_cache.cpp b/test/test_block_cache.cpp index b3ef7eed7..d8b5d59b6 100644 --- a/test/test_block_cache.cpp +++ b/test/test_block_cache.cpp @@ -40,8 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/session.hpp" #include -#include -#include +#include using namespace libtorrent; diff --git a/test/test_create_torrent.cpp b/test/test_create_torrent.cpp index 7373c6cbf..7fcf33c57 100644 --- a/test/test_create_torrent.cpp +++ b/test/test_create_torrent.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/create_torrent.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/aux_/escape_string.hpp" // for convert_path_to_posix -#include + #include namespace lt = libtorrent; diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index 7b48f6197..e07f9ac7c 100644 --- a/test/test_fast_extension.cpp +++ b/test/test_fast_extension.cpp @@ -405,7 +405,7 @@ entry read_ut_metadata_msg(tcp::socket& s, char* recv_buffer, int size) } std::shared_ptr setup_peer(tcp::socket& s, sha1_hash& ih - , boost::shared_ptr& ses, bool incoming = true + , std::shared_ptr& ses, bool incoming = true , int flags = 0, torrent_handle* th = nullptr) { std::shared_ptr t = ::create_torrent(); @@ -473,7 +473,7 @@ TORRENT_TEST(reject_fast) std::cerr << "\n === test reject ===\n" << std::endl; sha1_hash ih; - boost::shared_ptr ses; + std::shared_ptr ses; io_service ios; tcp::socket s(ios); setup_peer(s, ih, ses); @@ -542,7 +542,7 @@ TORRENT_TEST(invalid_suggest) std::cerr << "\n === test suggest ===\n" << std::endl; sha1_hash ih; - boost::shared_ptr ses; + std::shared_ptr ses; io_service ios; tcp::socket s(ios); setup_peer(s, ih, ses); @@ -582,7 +582,7 @@ TORRENT_TEST(reject_suggest) std::cerr << "\n === test suggest ===\n" << std::endl; sha1_hash ih; - boost::shared_ptr ses; + std::shared_ptr ses; io_service ios; tcp::socket s(ios); setup_peer(s, ih, ses); @@ -661,7 +661,7 @@ TORRENT_TEST(suggest_order) std::cerr << "\n === test suggest ===\n" << std::endl; sha1_hash ih; - boost::shared_ptr ses; + std::shared_ptr ses; io_service ios; tcp::socket s(ios); setup_peer(s, ih, ses); @@ -721,7 +721,7 @@ TORRENT_TEST(multiple_bitfields) std::cerr << "\n === test multiple bitfields ===\n" << std::endl; sha1_hash ih; - boost::shared_ptr ses; + std::shared_ptr ses; io_service ios; tcp::socket s(ios); std::shared_ptr ti = setup_peer(s, ih, ses); @@ -755,7 +755,7 @@ TORRENT_TEST(multiple_have_all) std::cerr << "\n === test multiple have_all ===\n" << std::endl; sha1_hash ih; - boost::shared_ptr ses; + std::shared_ptr ses; io_service ios; tcp::socket s(ios); std::shared_ptr ti = setup_peer(s, ih, ses); @@ -790,7 +790,7 @@ TORRENT_TEST(dont_have) sha1_hash ih; torrent_handle th; - boost::shared_ptr ses; + std::shared_ptr ses; io_service ios; tcp::socket s(ios); std::shared_ptr ti = setup_peer(s, ih, ses, true, 0, &th); @@ -892,7 +892,7 @@ TORRENT_TEST(invalid_metadata_request) std::cerr << "\n === test invalid metadata ===\n" << std::endl; sha1_hash ih; - boost::shared_ptr ses; + std::shared_ptr ses; io_service ios; tcp::socket s(ios); std::shared_ptr ti = setup_peer(s, ih, ses); @@ -945,7 +945,7 @@ TORRENT_TEST(invalid_request) std::cerr << "\n === test request ===\n" << std::endl; sha1_hash ih; - boost::shared_ptr ses; + std::shared_ptr ses; io_service ios; tcp::socket s(ios); setup_peer(s, ih, ses); @@ -965,7 +965,7 @@ TORRENT_TEST(invalid_request) void have_all_test(bool const incoming) { sha1_hash ih; - boost::shared_ptr ses; + std::shared_ptr ses; io_service ios; tcp::socket s(ios); setup_peer(s, ih, ses, incoming, add_torrent_params::flag_seed_mode); diff --git a/test/test_natpmp.cpp b/test/test_natpmp.cpp index 4b34b8b4c..f1264bc15 100644 --- a/test/test_natpmp.cpp +++ b/test/test_natpmp.cpp @@ -35,10 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/socket_io.hpp" #include #include - -#include -#include -#include +#include using namespace libtorrent; @@ -68,7 +65,7 @@ int main(int argc, char* argv[]) return 1; } - boost::shared_ptr natpmp_handler(new natpmp( + std::shared_ptr natpmp_handler(new natpmp( ios, &callback, &log_callback)); deadline_timer timer(ios); diff --git a/test/test_piece_picker.cpp b/test/test_piece_picker.cpp index b26ede4ad..da10f73ee 100644 --- a/test/test_piece_picker.cpp +++ b/test/test_piece_picker.cpp @@ -36,12 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/performance_counters.hpp" #include "libtorrent/random.hpp" -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#include - -#include "libtorrent/aux_/disable_warnings_pop.hpp" - +#include #include #include #include @@ -109,7 +104,7 @@ namespace { // have_str is a string where each character represents a // piece, ' ' means we don't have the piece and any other // character means we have it -boost::shared_ptr setup_picker( +std::shared_ptr setup_picker( char const* availability , char const* have_str , char const* priority @@ -118,7 +113,7 @@ boost::shared_ptr setup_picker( const int num_pieces = int(strlen(availability)); TORRENT_ASSERT(int(strlen(have_str)) == num_pieces); - boost::shared_ptr p(new piece_picker); + std::shared_ptr p(new piece_picker); p->init(blocks_per_piece, blocks_per_piece, num_pieces); for (int i = 0; i < num_pieces; ++i) @@ -212,7 +207,7 @@ boost::shared_ptr setup_picker( return p; } -bool verify_pick(boost::shared_ptr p +bool verify_pick(std::shared_ptr p , std::vector const& picked, bool allow_multi_blocks = false) { #if TORRENT_USE_INVARIANT_CHECKS @@ -235,7 +230,7 @@ bool verify_pick(boost::shared_ptr p return picked.size() == blocks.size(); } -void print_availability(boost::shared_ptr const& p) +void print_availability(std::shared_ptr const& p) { std::vector avail; p->get_availability(avail); @@ -248,7 +243,7 @@ void print_availability(boost::shared_ptr const& p) std::printf("]\n"); } -bool verify_availability(boost::shared_ptr const& p, char const* a) +bool verify_availability(std::shared_ptr const& p, char const* a) { std::vector avail; p->get_availability(avail); @@ -269,7 +264,7 @@ void print_pick(std::vector const& picked) std::cout << std::endl; } -std::vector pick_pieces(boost::shared_ptr const& p +std::vector pick_pieces(std::shared_ptr const& p , char const* availability , int num_blocks , int prefer_contiguous_blocks @@ -287,7 +282,7 @@ std::vector pick_pieces(boost::shared_ptr const& p return picked; } -int test_pick(boost::shared_ptr const& p +int test_pick(std::shared_ptr const& p , int options = piece_picker::rarest_first) { const std::vector empty_vector; diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 529316e28..982ca6b20 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -45,7 +45,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_info.hpp" #include "libtorrent/read_resume_data.hpp" -#include #include #include @@ -118,7 +117,7 @@ void run_until(io_service& ios, bool const& done) void nop() {} -boost::shared_ptr setup_torrent(file_storage& fs +std::shared_ptr setup_torrent(file_storage& fs , file_pool& fp , std::vector& buf , std::string const& test_path @@ -152,7 +151,7 @@ boost::shared_ptr setup_torrent(file_storage& fs p.pool = &fp; p.path = test_path; p.mode = storage_mode_allocate; - boost::shared_ptr s(new default_storage(p)); + std::shared_ptr s(new default_storage(p)); s->m_settings = &set; // allocate the files and create the directories @@ -316,7 +315,7 @@ void test_remove(std::string const& test_path, bool unbuffered) , unbuffered ? settings_pack::disable_os_cache : settings_pack::enable_os_cache); - boost::shared_ptr s = setup_torrent(fs, fp, buf, test_path, set); + std::shared_ptr s = setup_torrent(fs, fp, buf, test_path, set); // directories are not created up-front, unless they contain // an empty file (all of which are created up-front, along with @@ -382,7 +381,7 @@ void test_rename(std::string const& test_path) disk_buffer_pool dp(16 * 1024, ios, std::bind(&nop)); aux::session_settings set; - boost::shared_ptr s = setup_torrent(fs, fp, buf, test_path + std::shared_ptr s = setup_torrent(fs, fp, buf, test_path , set); // directories are not created up-front, unless they contain @@ -1285,7 +1284,7 @@ TORRENT_TEST(move_storage_into_self) file_pool fp; io_service ios; disk_buffer_pool dp(16 * 1024, ios, std::bind(&nop)); - boost::shared_ptr s = setup_torrent(fs, fp, buf, save_path, set); + std::shared_ptr s = setup_torrent(fs, fp, buf, save_path, set); file::iovec_t const b = {&buf[0], 4}; storage_error se; @@ -1331,7 +1330,7 @@ TORRENT_TEST(dont_move_intermingled_files) file_pool fp; io_service ios; disk_buffer_pool dp(16 * 1024, ios, std::bind(&nop)); - boost::shared_ptr s = setup_torrent(fs, fp, buf, save_path, set); + std::shared_ptr s = setup_torrent(fs, fp, buf, save_path, set); file::iovec_t b = {&buf[0], 4}; storage_error se; diff --git a/test/test_tracker.cpp b/test/test_tracker.cpp index ce4f22a96..d0bdafa62 100644 --- a/test/test_tracker.cpp +++ b/test/test_tracker.cpp @@ -476,7 +476,7 @@ TORRENT_TEST(current_tracker) pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:39775"); //pack.set_int(settings_pack::alert_mask, alert::tracker_notification); - boost::scoped_ptr s(new lt::session(pack)); + std::unique_ptr s(new lt::session(pack)); error_code ec; remove_all("tmp3_tracker", ec); diff --git a/test/test_upnp.cpp b/test/test_upnp.cpp index 5029c26de..d3ce3fefc 100644 --- a/test/test_upnp.cpp +++ b/test/test_upnp.cpp @@ -38,9 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include - -#include -#include +#include namespace lt = libtorrent; using namespace libtorrent; diff --git a/test/udp_tracker.cpp b/test/udp_tracker.cpp index eca0b503b..aff4cead4 100644 --- a/test/udp_tracker.cpp +++ b/test/udp_tracker.cpp @@ -43,11 +43,10 @@ POSSIBILITY OF SUCH DAMAGE. #include "test_utils.hpp" #include -#include -#include #include #include +#include using namespace libtorrent; using namespace std::placeholders; @@ -61,7 +60,7 @@ struct udp_tracker int m_port; bool m_abort; - boost::shared_ptr m_thread; + std::shared_ptr m_thread; void on_udp_receive(error_code const& ec, size_t bytes_transferred, udp::endpoint* from, char* buffer, int size) { @@ -170,7 +169,7 @@ struct udp_tracker std::fprintf(stderr, "%s: UDP tracker initialized on port %d\n", time_now_string(), m_port); - m_thread = boost::make_shared(&udp_tracker::thread_fun, this); + m_thread = std::make_shared(&udp_tracker::thread_fun, this); } void stop() @@ -219,7 +218,7 @@ struct udp_tracker } }; -boost::shared_ptr g_udp_tracker; +std::shared_ptr g_udp_tracker; int start_udp_tracker() {