diff --git a/bindings/python/src/converters.cpp b/bindings/python/src/converters.cpp index 8fd0c4a0b..376ab4d41 100644 --- a/bindings/python/src/converters.cpp +++ b/bindings/python/src/converters.cpp @@ -72,7 +72,7 @@ struct tuple_to_pair tuple_to_pair() { converter::registry::push_back( - &convertible, &construct, type_id >() + &convertible, &construct, type_id>() ); } @@ -84,7 +84,7 @@ struct tuple_to_pair static void construct(PyObject* x, converter::rvalue_from_python_stage1_data* data) { void* storage = ((converter::rvalue_from_python_storage< - std::pair >*)data)->storage.bytes; + std::pair>*)data)->storage.bytes; object o(borrowed(x)); std::pair p; @@ -115,7 +115,7 @@ struct list_to_vector list_to_vector() { converter::registry::push_back( - &convertible, &construct, type_id >() + &convertible, &construct, type_id>() ); } @@ -127,7 +127,7 @@ struct list_to_vector static void construct(PyObject* x, converter::rvalue_from_python_stage1_data* data) { void* storage = ((converter::rvalue_from_python_storage< - std::vector >*)data)->storage.bytes; + std::vector>*)data)->storage.bytes; std::vector p; int const size = int(PyList_Size(x)); @@ -146,16 +146,16 @@ struct list_to_vector void bind_converters() { // C++ -> python conversions - to_python_converter, pair_to_tuple >(); - to_python_converter, pair_to_tuple >(); - to_python_converter >(); - to_python_converter >(); - to_python_converter, vector_to_list >(); - to_python_converter, vector_to_list >(); - to_python_converter, vector_to_list >(); - to_python_converter, vector_to_list >(); - to_python_converter, vector_to_list >(); - to_python_converter >, vector_to_list > >(); + to_python_converter, pair_to_tuple>(); + to_python_converter, pair_to_tuple>(); + to_python_converter>(); + to_python_converter>(); + to_python_converter, vector_to_list>(); + to_python_converter, vector_to_list>(); + to_python_converter, vector_to_list>(); + to_python_converter, vector_to_list>(); + to_python_converter, vector_to_list>(); + to_python_converter>, vector_to_list>>(); // python -> C++ conversions tuple_to_pair(); @@ -167,6 +167,5 @@ void bind_converters() list_to_vector(); list_to_vector(); list_to_vector(); - list_to_vector >(); + list_to_vector>(); } - diff --git a/bindings/python/src/gil.hpp b/bindings/python/src/gil.hpp index 9ce9c90cc..6dd1dc688 100644 --- a/bindings/python/src/gil.hpp +++ b/bindings/python/src/gil.hpp @@ -98,7 +98,7 @@ struct allow_threading }; template -struct visitor : boost::python::def_visitor > +struct visitor : boost::python::def_visitor> { visitor(F fn) : fn(fn) @@ -145,4 +145,3 @@ visitor allow_threads(F fn) //}} // namespace libtorrent::python #endif // GIL_070107_HPP - diff --git a/bindings/python/src/magnet_uri.cpp b/bindings/python/src/magnet_uri.cpp index 4255b3b1f..509deba0a 100644 --- a/bindings/python/src/magnet_uri.cpp +++ b/bindings/python/src/magnet_uri.cpp @@ -54,9 +54,8 @@ namespace { ret["trackers"] = tracker_list; list nodes_list; - for (std::vector >::const_iterator i = p.dht_nodes.begin() - , end(p.dht_nodes.end()); i != end; ++i) - tracker_list.append(boost::python::make_tuple(i->first, i->second)); + for (auto const& i : p.dht_nodes) + tracker_list.append(boost::python::make_tuple(i.first, i.second)); ret["dht_nodes"] = nodes_list; ret["info_hash"] = p.info_hash; ret["name"] = p.name; @@ -83,4 +82,3 @@ void bind_magnet_uri() def("make_magnet_uri", make_magnet_uri1); def("parse_magnet_uri", parse_magnet_uri_wrap); } - diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index b1b10d92f..ac1ec2889 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -238,7 +238,7 @@ namespace list l = extract(params["dht_nodes"]); int const n = int(boost::python::len(l)); for(int i = 0; i < n; i++) - p.dht_nodes.push_back(extract >(l[i])); + p.dht_nodes.push_back(extract>(l[i])); } if (params.has_key("flags")) p.flags = extract(params["flags"]); @@ -854,4 +854,3 @@ void bind_session() #ifdef _MSC_VER #pragma warning(pop) #endif - diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index f756740a0..12f86efec 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -144,13 +144,13 @@ void prioritize_pieces(torrent_handle& info, object o) // determine which overload should be selected. the one taking a list of // priorities or the one taking a list of piece -> priority mappings - bool const is_piece_list = extract >(*begin).check(); + bool const is_piece_list = extract>(*begin).check(); if (is_piece_list) { - std::vector > piece_list; + std::vector> piece_list; std::transform(begin, end, std::back_inserter(piece_list) - , &extract_fn >); + , &extract_fn>); info.prioritize_pieces(piece_list); } else @@ -503,4 +503,3 @@ void bind_torrent_handle() #ifdef _MSC_VER #pragma warning(pop) #endif - diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index 4ac14c9bd..854cded62 100644 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -43,12 +43,8 @@ namespace { list result; - typedef std::vector > list_type; - - for (list_type::const_iterator i = ti.nodes().begin(); i != ti.nodes().end(); ++i) - { - result.append(boost::python::make_tuple(i->first, i->second)); - } + for (auto const& i : ti.nodes()) + result.append(boost::python::make_tuple(i.first, i.second)); return result; } @@ -212,7 +208,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)) @@ -319,4 +315,3 @@ void bind_torrent_info() #ifdef _MSC_VER #pragma warning(pop) #endif - diff --git a/examples/connection_tester.cpp b/examples/connection_tester.cpp index e786625d3..ff4f569cb 100644 --- a/examples/connection_tester.cpp +++ b/examples/connection_tester.cpp @@ -818,7 +818,7 @@ void generate_torrent(std::vector& buf, int size, int num_files t3.join(); t4.join(); - std::back_insert_iterator > out(buf); + std::back_insert_iterator> out(buf); bencode(out, t.generate()); } @@ -990,7 +990,7 @@ int main(int argc, char* argv[]) buf.clear(); - std::back_insert_iterator > out(buf); + std::back_insert_iterator> out(buf); bencode(out, t.generate()); FILE* f = std::fopen(torrent_name, "w+"); if (f == nullptr) diff --git a/examples/dump_torrent.cpp b/examples/dump_torrent.cpp index 75c950644..bb872989f 100644 --- a/examples/dump_torrent.cpp +++ b/examples/dump_torrent.cpp @@ -159,20 +159,12 @@ int main(int argc, char* argv[]) // print info about torrent std::printf("\n\n----- torrent file info -----\n\n" "nodes:\n"); + for (auto const& i : t.nodes()) + std::printf("%s: %d\n", i.first.c_str(), i.second); - typedef std::vector > node_vec; - node_vec const& nodes = t.nodes(); - for (node_vec::const_iterator i = nodes.begin(), end(nodes.end()); - i != end; ++i) - { - std::printf("%s: %d\n", i->first.c_str(), i->second); - } puts("trackers:\n"); - for (std::vector::const_iterator i = t.trackers().begin(); - i != t.trackers().end(); ++i) - { - std::printf("%2d: %s\n", i->tier, i->url.c_str()); - } + for (auto const& i : t.trackers()) + std::printf("%2d: %s\n", i.tier, i.url.c_str()); std::stringstream ih; ih << t.info_hash(); @@ -226,4 +218,3 @@ int main(int argc, char* argv[]) return 0; } - diff --git a/include/libtorrent/aux_/time.hpp b/include/libtorrent/aux_/time.hpp index 46af95714..fdca9eea5 100644 --- a/include/libtorrent/aux_/time.hpp +++ b/include/libtorrent/aux_/time.hpp @@ -47,4 +47,3 @@ namespace libtorrent { namespace aux } } #endif - diff --git a/include/libtorrent/file_pool.hpp b/include/libtorrent/file_pool.hpp index aba62ccb9..532d60eb7 100644 --- a/include/libtorrent/file_pool.hpp +++ b/include/libtorrent/file_pool.hpp @@ -35,13 +35,15 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include + #include "libtorrent/file.hpp" -#include "libtorrent/time.hpp" -#include "libtorrent/file_storage.hpp" #include "libtorrent/aux_/time.hpp" namespace libtorrent { + class file_storage; + struct pool_file_status { // the index of the file this entry refers to into the ``file_storage`` @@ -136,11 +138,9 @@ namespace libtorrent // maps storage pointer, file index pairs to the // lru entry for the file - using file_set = std::map, lru_file_entry>; - - file_set m_files; + std::map, lru_file_entry> m_files; #if TORRENT_USE_ASSERTS - std::vector > m_deleted_storages; + std::vector> m_deleted_storages; #endif mutable std::mutex m_mutex; }; diff --git a/include/libtorrent/http_parser.hpp b/include/libtorrent/http_parser.hpp index dddf8281e..678d1adf3 100644 --- a/include/libtorrent/http_parser.hpp +++ b/include/libtorrent/http_parser.hpp @@ -136,7 +136,7 @@ namespace libtorrent span m_recv_buffer; // contains offsets of the first and one-past-end of // each chunked range in the response - std::vector > m_chunked_ranges; + std::vector> m_chunked_ranges; // while reading a chunk, this is the offset where the // current chunk will end (it refers to the first character @@ -167,4 +167,3 @@ namespace libtorrent } #endif // TORRENT_HTTP_PARSER_HPP_INCLUDED - diff --git a/include/libtorrent/ip_filter.hpp b/include/libtorrent/ip_filter.hpp index 3226467df..14427be86 100644 --- a/include/libtorrent/ip_filter.hpp +++ b/include/libtorrent/ip_filter.hpp @@ -207,9 +207,9 @@ namespace detail } template - std::vector > export_filter() const + std::vector> export_filter() const { - std::vector > ret; + std::vector> ret; ret.reserve(m_access_list.size()); for (typename range_t::const_iterator i = m_access_list.begin() @@ -288,10 +288,10 @@ struct TORRENT_EXPORT ip_filter int access(address const& addr) const; #if TORRENT_USE_IPV6 - using filter_tuple_t = std::tuple > - , std::vector > >; + using filter_tuple_t = std::tuple> + , std::vector>>; #else - using filter_tuple_t = std::vector >; + using filter_tuple_t = std::vector>; #endif // This function will return the current state of the filter in the minimum number of @@ -348,4 +348,3 @@ private: } #endif - diff --git a/include/libtorrent/kademlia/rpc_manager.hpp b/include/libtorrent/kademlia/rpc_manager.hpp index cf9f6070a..326c9db7c 100644 --- a/include/libtorrent/kademlia/rpc_manager.hpp +++ b/include/libtorrent/kademlia/rpc_manager.hpp @@ -120,7 +120,9 @@ private: std::unordered_multimap m_transactions; udp_socket_interface* m_sock; +#ifndef TORRENT_DISABLE_LOGGING dht_logger* m_log; +#endif dht_settings const& m_settings; routing_table& m_table; node_id m_our_id; diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index d3e31e368..89596feca 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -87,7 +87,7 @@ POSSIBILITY OF SUCH DAMAGE. // virtual bool has_any_file() { return false; } // virtual int read(char* buf, int piece, int offset, int size) // { -// std::map >::const_iterator i = m_file_data.find(piece); +// std::map>::const_iterator i = m_file_data.find(piece); // if (i == m_file_data.end()) return 0; // int available = i->second.size() - offset; // if (available <= 0) return 0; @@ -129,7 +129,7 @@ POSSIBILITY OF SUCH DAMAGE. // virtual bool release_files() { return false; } // virtual bool delete_files() { return false; } // -// std::map > m_file_data; +// std::map> m_file_data; // file_storage m_files; // }; // diff --git a/include/libtorrent/tailqueue.hpp b/include/libtorrent/tailqueue.hpp index 260342158..0fd3c6ef7 100644 --- a/include/libtorrent/tailqueue.hpp +++ b/include/libtorrent/tailqueue.hpp @@ -55,7 +55,7 @@ namespace libtorrent template struct tailqueue_iterator { - template friend struct tailqueue; + template friend struct tailqueue; T* get() const { return m_current; } void next() { m_current = m_current->next; } @@ -67,8 +67,8 @@ namespace libtorrent T* m_current; }; - template -//#error boost::enable_if< is_base > > + template , T>::value>::type> struct tailqueue { tailqueue(): m_first(nullptr), m_last(nullptr), m_size(0) {} @@ -185,4 +185,3 @@ namespace libtorrent } #endif // TAILQUEUE_HPP - diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 0f43f50f3..b99d0b00c 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -526,7 +526,7 @@ namespace libtorrent int piece_priority(int index) const; void prioritize_pieces(std::vector const& pieces); - void prioritize_piece_list(std::vector > const& pieces); + void prioritize_piece_list(std::vector> const& pieces); void piece_priorities(std::vector*) const; void set_file_priority(int index, int priority); diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index e8fcaca48..184486ad9 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -1015,7 +1015,7 @@ namespace libtorrent void piece_priority(int index, int priority) const; int piece_priority(int index) const; void prioritize_pieces(std::vector const& pieces) const; - void prioritize_pieces(std::vector > const& pieces) const; + void prioritize_pieces(std::vector> const& pieces) const; std::vector piece_priorities() const; // ``index`` must be in the range [0, number_of_files). diff --git a/simulation/test_web_seed.cpp b/simulation/test_web_seed.cpp index 4bc93c087..9de118093 100644 --- a/simulation/test_web_seed.cpp +++ b/simulation/test_web_seed.cpp @@ -104,7 +104,7 @@ add_torrent_params create_torrent(file_storage& fs, bool const pad_files = false } std::vector tmp; - std::back_insert_iterator > out(tmp); + std::back_insert_iterator> out(tmp); entry tor = t.generate(); diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 60c43faba..c0c790e0e 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -900,7 +900,7 @@ namespace libtorrent DLOG("try_flush_write_blocks: %d\n", num); list_iterator range = m_disk_cache.write_lru_pieces(); - std::vector > pieces; + std::vector> pieces; pieces.reserve(m_disk_cache.num_write_lru_pieces()); for (list_iterator p = range; p.get() && num > 0; p.next()) @@ -910,12 +910,11 @@ namespace libtorrent pieces.push_back(std::make_pair(e->storage.get(), int(e->piece))); } - for (std::vector >::iterator i = pieces.begin() - , end(pieces.end()); i != end; ++i) + for (auto const& p : pieces) { // TODO: instead of doing a lookup each time through the loop, save // cached_piece_entry pointers with piece_refcount incremented to pin them - cached_piece_entry* pe = m_disk_cache.find_piece(i->first, i->second); + cached_piece_entry* pe = m_disk_cache.find_piece(p.first, p.second); if (pe == nullptr) continue; // another thread may flush this piece while we're looping and @@ -942,10 +941,9 @@ namespace libtorrent // if we still need to flush blocks, start over and flush // everything in LRU order (degrade to lru cache eviction) - for (std::vector >::iterator i = pieces.begin() - , end(pieces.end()); i != end; ++i) + for (auto const& p : pieces) { - cached_piece_entry* pe = m_disk_cache.find_piece(i->first, i->second); + cached_piece_entry* pe = m_disk_cache.find_piece(p.first, p.second); if (pe == nullptr) continue; if (pe->num_dirty == 0) continue; diff --git a/src/file_pool.cpp b/src/file_pool.cpp index 7167554a3..caa8980c8 100644 --- a/src/file_pool.cpp +++ b/src/file_pool.cpp @@ -35,8 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #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 "libtorrent/file_storage.hpp" #include @@ -141,7 +140,7 @@ namespace libtorrent TORRENT_ASSERT(is_complete(p)); TORRENT_ASSERT((m & file::rw_mask) == file::read_only || (m & file::rw_mask) == file::read_write); - file_set::iterator i = m_files.find(std::make_pair(st, file_index)); + auto const i = m_files.find(std::make_pair(st, file_index)); if (i != m_files.end()) { lru_file_entry& e = i->second; @@ -227,22 +226,21 @@ namespace libtorrent { std::unique_lock l(m_mutex); - auto start = m_files.lower_bound(std::make_pair(st, 0)); - auto end = m_files.upper_bound(std::make_pair(st - , std::numeric_limits::max())); + auto const start = m_files.lower_bound(std::make_pair(st, 0)); + auto const end = m_files.upper_bound(std::make_pair(st + , std::numeric_limits::max())); - for (file_set::const_iterator i = start; i != end; ++i) - { + for (auto i = start; i != end; ++i) ret.push_back({i->first.second, i->second.mode, i->second.last_use}); - } } return ret; } void file_pool::remove_oldest(std::unique_lock& l) { - file_set::iterator i = std::min_element(m_files.begin(), m_files.end() - , [] (file_set::value_type const& lhs, file_set::value_type const& rhs) + using value_type = std::map, lru_file_entry>::value_type; + auto const i = std::min_element(m_files.begin(), m_files.end() + , [] (value_type const& lhs, value_type const& rhs) { return lhs.second.last_use < rhs.second.last_use; }); if (i == m_files.end()) return; @@ -259,7 +257,7 @@ namespace libtorrent { std::unique_lock l(m_mutex); - file_set::iterator i = m_files.find(std::make_pair(st, file_index)); + auto const i = m_files.find(std::make_pair(st, file_index)); if (i == m_files.end()) return; file_handle file_ptr = i->second.file_ptr; @@ -278,15 +276,14 @@ namespace libtorrent if (st == nullptr) { - file_set tmp; + std::map, lru_file_entry> tmp; tmp.swap(m_files); l.unlock(); return; } std::vector to_close; - for (file_set::iterator i = m_files.begin(); - i != m_files.end();) + for (auto i = m_files.begin(); i != m_files.end();) { if (i->second.key == st) { @@ -314,10 +311,9 @@ namespace libtorrent { std::unique_lock l(m_mutex); - for (file_set::const_iterator i = m_files.begin(); - i != m_files.end(); ++i) + for (auto const& i : m_files) { - if (i->second.key == st && !i->second.file_ptr.unique()) + if (i.second.key == st && !i.second.file_ptr.unique()) return false; } return true; @@ -340,4 +336,3 @@ namespace libtorrent } } - diff --git a/src/http_connection.cpp b/src/http_connection.cpp index 5971725a9..8f2930621 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -565,8 +565,8 @@ void http_connection::connect() #ifdef TORRENT_USE_OPENSSL if (m_ssl) { - TORRENT_ASSERT(m_sock.get >()); - m_sock.get >()->next_layer().set_dst_name(m_hostname); + TORRENT_ASSERT(m_sock.get>()); + m_sock.get>()->next_layer().set_dst_name(m_hostname); } else #endif diff --git a/src/kademlia/dos_blocker.cpp b/src/kademlia/dos_blocker.cpp index 006c6b38c..fbbf7897d 100644 --- a/src/kademlia/dos_blocker.cpp +++ b/src/kademlia/dos_blocker.cpp @@ -84,7 +84,9 @@ namespace libtorrent { namespace dht , total_milliseconds((now - match->limit) + seconds(10)) / 1000.0 , match->count); } -#endif +#else + TORRENT_UNUSED(logger); +#endif // TORRENT_DISABLE_LOGGING // we've received too many messages in less than 10 seconds // from this node. Ignore it until it's silent for 5 minutes match->limit = now + seconds(m_block_timeout); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 2acae3a11..1eda77224 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -2337,8 +2337,8 @@ namespace aux { // use the generic m_ssl_ctx context. However, since it has // the servername callback set on it, we will switch away from // this context into a specific torrent once we start handshaking - c->instantiate >(m_io_service, &m_ssl_ctx); - str = &c->get >()->next_layer(); + c->instantiate>(m_io_service, &m_ssl_ctx); + str = &c->get>()->next_layer(); } else #endif @@ -2952,8 +2952,7 @@ 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::remove_if(m_undead_peers.begin(), m_undead_peers.end() + auto const remove_it = std::remove_if(m_undead_peers.begin(), m_undead_peers.end() , std::bind(&std::shared_ptr::unique, _1)); m_undead_peers.erase(remove_it, m_undead_peers.end()); if (m_undead_peers.empty()) @@ -3296,10 +3295,9 @@ namespace aux { { // if we haven't reached the global max. see if any torrent // has reached its local limit - for (torrent_map::iterator i = m_torrents.begin() - , end(m_torrents.end()); i != end; ++i) + for (auto const& pt : m_torrents) { - std::shared_ptr t = i->second; + std::shared_ptr t = pt.second; // ths disconnect logic is disabled for torrents with // too low connection limit @@ -3308,11 +3306,10 @@ namespace aux { || t->max_connections() < 6) continue; - int peers_to_disconnect = (std::min)((std::max)(int(t->num_peers() - * m_settings.get_int(settings_pack::peer_turnover) / 100), 1) + int peers_to_disconnect = (std::min)((std::max)(t->num_peers() + * m_settings.get_int(settings_pack::peer_turnover) / 100, 1) , t->num_connect_candidates()); - t->disconnect_peers(peers_to_disconnect - , error_code(errors::optimistic_disconnect)); + t->disconnect_peers(peers_to_disconnect, errors::optimistic_disconnect); } } } @@ -4312,22 +4309,20 @@ namespace aux { { TORRENT_ASSERT(is_single_thread()); - std::map >::const_iterator i - = m_uuids.find(uuid); + auto const i = m_uuids.find(uuid); if (i != m_uuids.end()) return i->second; return std::weak_ptr(); } #endif #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS - std::vector > session_impl::find_collection( + std::vector> session_impl::find_collection( std::string const& collection) const { - std::vector > ret; - for (session_impl::torrent_map::const_iterator i = m_torrents.begin() - , end(m_torrents.end()); i != end; ++i) + std::vector> ret; + for (auto const& tp : m_torrents) { - std::shared_ptr t = i->second; + std::shared_ptr t = tp.second; if (!t) continue; std::vector const& c = t->torrent_file().collections(); if (std::find(c.begin(), c.end(), collection) == c.end()) continue; @@ -4729,11 +4724,8 @@ namespace aux { // add params.dht_nodes to the DHT, if enabled if (!params.dht_nodes.empty()) { - for (std::vector >::const_iterator i = params.dht_nodes.begin() - , end(params.dht_nodes.end()); i != end; ++i) - { - add_dht_node_name(*i); - } + for (auto const& n : params.dht_nodes) + add_dht_node_name(n); } #endif @@ -4936,14 +4928,12 @@ namespace aux { // remove from uuid list if (!tptr->uuid().empty()) { - std::map >::iterator j - = m_uuids.find(tptr->uuid()); + auto const j = m_uuids.find(tptr->uuid()); if (j != m_uuids.end()) m_uuids.erase(j); } #endif - torrent_map::iterator i = - m_torrents.find(tptr->torrent_file().info_hash()); + auto i = m_torrents.find(tptr->torrent_file().info_hash()); #ifndef TORRENT_NO_DEPRECATE // deprecated in 1.2 @@ -6746,10 +6736,8 @@ namespace aux { } } - for (std::vector >::const_iterator i - = m_undead_peers.begin(); i != m_undead_peers.end(); ++i) + for (auto const& p : m_undead_peers) { - peer_connection* p = i->get(); if (p->ignore_unchoke_slots()) { if (!p->is_choked()) ++unchokes_all; diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 2ac094dac..f15e092a8 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -436,7 +436,7 @@ namespace libtorrent async_call(&torrent::prioritize_pieces, pieces); } - void torrent_handle::prioritize_pieces(std::vector > const& pieces) const + void torrent_handle::prioritize_pieces(std::vector> const& pieces) const { async_call(&torrent::prioritize_piece_list, pieces); } diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 9c9665e1b..b9b967347 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -818,7 +818,7 @@ namespace libtorrent torrent_info::torrent_info(entry const& torrent_file) { std::vector tmp; - std::back_insert_iterator > out(tmp); + std::back_insert_iterator> out(tmp); bencode(out, torrent_file); bdecode_node e; diff --git a/test/make_torrent.cpp b/test/make_torrent.cpp index e8f73f1ac..9fb6b3de4 100644 --- a/test/make_torrent.cpp +++ b/test/make_torrent.cpp @@ -57,7 +57,7 @@ std::shared_ptr make_test_torrent( // torrent offset ranges where the pad files are // used when generating hashes - std::deque > pad_files; + std::deque> pad_files; int const piece_length = 32768; info["piece length"] = piece_length; @@ -152,7 +152,7 @@ std::shared_ptr make_test_torrent( info["pieces"] = piece_hashes; std::vector tmp; - std::back_insert_iterator > out(tmp); + std::back_insert_iterator> out(tmp); bencode(out, e); FILE* f = fopen("test.torrent", "w+"); @@ -198,5 +198,3 @@ void generate_files(libtorrent::torrent_info const& ti, std::string const& path } } } - - diff --git a/test/test_dht.cpp b/test/test_dht.cpp index 3543e889f..eda12faaf 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -104,7 +104,7 @@ void node_push_back(void* userdata, libtorrent::dht::node_entry const& n) void nop(void* userdata, libtorrent::dht::node_entry const& n) {} void nop_node() {} -std::list > g_sent_packets; +std::list> g_sent_packets; struct mock_socket final : udp_socket_interface { @@ -125,7 +125,7 @@ sha1_hash generate_next() return ret; } -std::list >::iterator +std::list>::iterator find_packet(udp::endpoint ep) { return std::find_if(g_sent_packets.begin(), g_sent_packets.end() @@ -242,7 +242,7 @@ void send_dht_request(node& node, char const* msg, udp::endpoint const& ep // If the request is supposed to get a response, by now the node should have // invoked the send function and put the response in g_sent_packets - std::list >::iterator i = find_packet(ep); + auto const i = find_packet(ep); if (has_response) { if (i == g_sent_packets.end()) @@ -1977,21 +1977,20 @@ void test_get_peers(address(&rand_addr)()) send_dht_response(t.dht_node, response, next_node , msg_args().token("11").port(1234).peers(peers[1])); - for (std::list >::iterator i = g_sent_packets.begin() - , end(g_sent_packets.end()); i != end; ++i) + for (auto const& p : g_sent_packets) { // std::printf(" %s:%d: %s\n", i->first.address().to_string(ec).c_str() // , i->first.port(), i->second.to_string().c_str()); - TEST_EQUAL(i->second["q"].string(), "announce_peer"); + TEST_EQUAL(p.second["q"].string(), "announce_peer"); } g_sent_packets.clear(); for (int i = 0; i < 2; ++i) { - for (std::set::iterator peer = peers[i].begin(); peer != peers[i].end(); ++peer) + for (auto const& peer : peers[i]) { - TEST_CHECK(std::find(g_got_peers.begin(), g_got_peers.end(), *peer) != g_got_peers.end()); + TEST_CHECK(std::find(g_got_peers.begin(), g_got_peers.end(), peer) != g_got_peers.end()); } } g_got_peers.clear(); @@ -2212,7 +2211,7 @@ TORRENT_TEST(immutable_put) for (int i = 0; i < 8; ++i) { - std::list >::iterator packet = find_packet(nodes[i].ep()); + auto const packet = find_packet(nodes[i].ep()); TEST_CHECK(packet != g_sent_packets.end()); if (packet == g_sent_packets.end()) continue; @@ -2241,7 +2240,7 @@ TORRENT_TEST(immutable_put) for (int i = 0; i < 8; ++i) { - std::list >::iterator packet = find_packet(nodes[i].ep()); + auto const packet = find_packet(nodes[i].ep()); TEST_CHECK(packet != g_sent_packets.end()); if (packet == g_sent_packets.end()) continue; @@ -2313,7 +2312,7 @@ TORRENT_TEST(mutable_put) for (int i = 0; i < 8; ++i) { - std::list >::iterator packet = find_packet(nodes[i].ep()); + auto const packet = find_packet(nodes[i].ep()); TEST_CHECK(packet != g_sent_packets.end()); if (packet == g_sent_packets.end()) continue; @@ -2342,7 +2341,7 @@ TORRENT_TEST(mutable_put) for (int i = 0; i < 8; ++i) { - std::list >::iterator packet = find_packet(nodes[i].ep()); + auto const packet = find_packet(nodes[i].ep()); TEST_CHECK(packet != g_sent_packets.end()); if (packet == g_sent_packets.end()) continue; @@ -2428,7 +2427,7 @@ TORRENT_TEST(traversal_done) // get_item_cb if (i == num_test_nodes) i = 0; - std::list >::iterator packet = find_packet(nodes[i].ep()); + auto const packet = find_packet(nodes[i].ep()); TEST_CHECK(packet != g_sent_packets.end()); if (packet == g_sent_packets.end()) continue; diff --git a/test/test_ip_filter.cpp b/test/test_ip_filter.cpp index 38aa9041e..e5e1b8831 100644 --- a/test/test_ip_filter.cpp +++ b/test/test_ip_filter.cpp @@ -61,9 +61,9 @@ bool compare(ip_range const& lhs } template -void test_rules_invariant(std::vector > const& r, ip_filter const& f) +void test_rules_invariant(std::vector> const& r, ip_filter const& f) { - typedef typename std::vector >::const_iterator iterator; + typedef typename std::vector>::const_iterator iterator; TEST_CHECK(!r.empty()); if (r.empty()) return; @@ -104,7 +104,7 @@ TORRENT_TEST(ip_filter) { using namespace libtorrent; - std::vector > range; + std::vector> range; error_code ec; // **** test joining of ranges at the end **** @@ -268,7 +268,7 @@ TORRENT_TEST(ip_filter) f.add_rule(addr("2::1"), addr("3::"), ip_filter::blocked); f.add_rule(addr("1::"), addr("2::"), ip_filter::blocked); - std::vector > range; + std::vector> range; range = std::get<1>(f.export_filter()); test_rules_invariant(range, f); @@ -297,4 +297,3 @@ TORRENT_TEST(ip_filter) TEST_CHECK(pf.access(6881) == 0); TEST_CHECK(pf.access(65535) == 0); } - diff --git a/test/test_peer_list.cpp b/test/test_peer_list.cpp index bed7cc2cf..3096a7f1a 100644 --- a/test/test_peer_list.cpp +++ b/test/test_peer_list.cpp @@ -143,16 +143,15 @@ struct mock_torrent peer_list* m_p; torrent_state* m_state; - std::vector > m_connections; + std::vector> m_connections; }; void mock_peer_connection::disconnect(error_code const& ec , operation_t op, int error) { m_torrent.m_p->connection_closed(*this, 0, m_torrent.m_state); - std::vector >::iterator i - = std::find(m_torrent.m_connections.begin(), m_torrent.m_connections.end() - , std::static_pointer_cast(shared_from_this())); + auto const i = std::find(m_torrent.m_connections.begin(), m_torrent.m_connections.end() + , std::static_pointer_cast(shared_from_this())); if (i != m_torrent.m_connections.end()) m_torrent.m_connections.erase(i); m_tp = nullptr; @@ -161,8 +160,7 @@ void mock_peer_connection::disconnect(error_code const& ec bool has_peer(peer_list const& p, tcp::endpoint const& ep) { - std::pair its - = p.find_peers(ep.address()); + auto const its = p.find_peers(ep.address()); return its.first != its.second; } @@ -939,4 +937,3 @@ TORRENT_TEST(new_peer_size_limit) // TODO: test connect_to_peer() failing // TODO: test connection_closed // TODO: connect candidates recalculation when incrementing failcount - diff --git a/test/test_piece_picker.cpp b/test/test_piece_picker.cpp index 3935c8af0..a1bfcbbf2 100644 --- a/test/test_piece_picker.cpp +++ b/test/test_piece_picker.cpp @@ -225,7 +225,7 @@ bool verify_pick(std::shared_ptr p // make sure there are no duplicated std::set blocks; std::copy(picked.begin(), picked.end() - , std::insert_iterator >(blocks, blocks.end())); + , std::insert_iterator>(blocks, blocks.end())); std::cout << " verify: " << picked.size() << " " << blocks.size() << std::endl; return picked.size() == blocks.size(); } @@ -1979,4 +1979,3 @@ TORRENT_TEST(download_filtered_piece) } //TODO: 2 test picking with partial pieces and other peers present so that both backup_pieces and backup_pieces2 are used - diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 6d2ce77ef..52f4e0d3d 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -1049,7 +1049,7 @@ struct test_fileop : fileop } int m_stripe_size; - std::vector > m_file_data; + std::vector> m_file_data; }; struct test_read_fileop : fileop diff --git a/test/test_torrent.cpp b/test/test_torrent.cpp index adc7748d3..c35a54f9a 100644 --- a/test/test_torrent.cpp +++ b/test/test_torrent.cpp @@ -269,7 +269,7 @@ TORRENT_TEST(torrent) t.set_hash(i, ph); std::vector tmp; - std::back_insert_iterator > out(tmp); + std::back_insert_iterator> out(tmp); bencode(out, t.generate()); error_code ec; auto info = std::make_shared(&tmp[0], int(tmp.size()), std::ref(ec), 0); @@ -340,7 +340,7 @@ TORRENT_TEST(duplicate_is_not_error) t.set_hash(i, ph); std::vector tmp; - std::back_insert_iterator > out(tmp); + std::back_insert_iterator> out(tmp); bencode(out, t.generate()); error_code ec; @@ -411,4 +411,3 @@ TORRENT_TEST(rename_file) TEST_EQUAL(info->files().file_path(0), "tmp1"); } - diff --git a/test/test_torrent_info.cpp b/test/test_torrent_info.cpp index 0a80ea5e7..b36eeb88d 100644 --- a/test/test_torrent_info.cpp +++ b/test/test_torrent_info.cpp @@ -64,7 +64,7 @@ TORRENT_TEST(mutable_torrents) t.add_similar_torrent(sha1_hash("babababababababababa")); std::vector tmp; - std::back_insert_iterator > out(tmp); + std::back_insert_iterator> out(tmp); entry tor = t.generate(); bencode(out, tor); @@ -798,7 +798,7 @@ void test_resolve_duplicates(int test_case) t.set_hash(i, ph); std::vector tmp; - std::back_insert_iterator > out(tmp); + std::back_insert_iterator> out(tmp); entry tor = t.generate(); bencode(out, tor);