diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 4ea94c09d..bc2faccae 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -49,10 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include // for va_start, va_end - -#if TORRENT_HAS_BOOST_UNORDERED -#include -#endif +#include #ifdef TORRENT_USE_OPENSSL #include "libtorrent/ssl_stream.hpp" @@ -202,11 +199,7 @@ namespace libtorrent friend class libtorrent::invariant_access; #endif typedef std::set > connection_map; -#if TORRENT_HAS_BOOST_UNORDERED - typedef boost::unordered_map > torrent_map; -#else - typedef std::map > torrent_map; -#endif + typedef std::unordered_map > torrent_map; session_impl(io_service& ios); virtual ~session_impl(); diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 2320152ac..ffde6fe08 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -587,10 +587,6 @@ int snprintf(char* buf, int len, char const* fmt, ...) #define TORRENT_USE_I2P 1 #endif -#ifndef TORRENT_HAS_BOOST_UNORDERED -#define TORRENT_HAS_BOOST_UNORDERED 1 -#endif - #if !defined TORRENT_IOV_MAX #ifdef IOV_MAX #define TORRENT_IOV_MAX IOV_MAX diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index 86c860a0a..b4a929a23 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #include @@ -498,7 +499,7 @@ namespace libtorrent // levels. i.e. if one path in the torrent is ``foo/bar/baz``, the CRC32 // hashes for ``foo``, ``foo/bar`` and ``foo/bar/baz`` will be added to // the set. - void all_path_hashes(boost::unordered_set& table) const; + void all_path_hashes(std::unordered_set& table) const; // flags indicating various attributes for files in // a file_storage. diff --git a/include/libtorrent/kademlia/rpc_manager.hpp b/include/libtorrent/kademlia/rpc_manager.hpp index 55c40c3ae..c41258c5e 100644 --- a/include/libtorrent/kademlia/rpc_manager.hpp +++ b/include/libtorrent/kademlia/rpc_manager.hpp @@ -35,23 +35,15 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_push.hpp" -#include -#include -#include +#include + #include #include #include -#if TORRENT_HAS_BOOST_UNORDERED -#include -#else -#include -#endif - #include "libtorrent/aux_/disable_warnings_pop.hpp" #include -#include #include #include @@ -59,7 +51,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { namespace aux { struct session_impl; } } -namespace libtorrent { struct dht_settings; } +namespace libtorrent { struct dht_settings; class entry; } namespace libtorrent { namespace dht { @@ -117,11 +109,7 @@ private: mutable boost::pool<> m_pool_allocator; -#if TORRENT_HAS_BOOST_UNORDERED - typedef boost::unordered_multimap transactions_t; -#else - typedef std::multimap transactions_t; -#endif + typedef std::unordered_multimap transactions_t; transactions_t m_transactions; udp_socket_interface* m_sock; diff --git a/include/libtorrent/sha1_hash.hpp b/include/libtorrent/sha1_hash.hpp index c86e9f446..d17fd920c 100644 --- a/include/libtorrent/sha1_hash.hpp +++ b/include/libtorrent/sha1_hash.hpp @@ -319,6 +319,7 @@ namespace libtorrent }; + // this is here to support usage of sha1_hash in boost unordered containers typedef sha1_hash peer_id; inline std::size_t hash_value(sha1_hash const& b) { @@ -349,5 +350,20 @@ namespace libtorrent #endif // TORRENT_USE_IOSTREAM } +namespace std { + + template <> + struct hash + { + std::size_t operator()(libtorrent::sha1_hash const& k) const + { + std::size_t ret; + // this is OK because sha1_hash is already a hash + std::memcpy(&ret, k.data(), sizeof(ret)); + return ret; + } + }; +} + #endif // TORRENT_PEER_ID_HPP_INCLUDED diff --git a/src/file_storage.cpp b/src/file_storage.cpp index c74a91101..81d234ae7 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -637,7 +637,7 @@ namespace libtorrent template void process_path_lowercase( - boost::unordered_set& table + std::unordered_set& table , CRC crc , char const* str, int len) { @@ -653,7 +653,7 @@ namespace libtorrent } void file_storage::all_path_hashes( - boost::unordered_set& table) const + std::unordered_set& table) const { boost::crc_optimal<32, 0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF, true, true> crc; diff --git a/src/session_impl.cpp b/src/session_impl.cpp index ed2b1b3ad..cdafcc4da 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -40,11 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #if defined TORRENT_DEBUG && !defined TORRENT_DISABLE_INVARIANT_CHECKS -#if TORRENT_HAS_BOOST_UNORDERED -#include -#else -#include -#endif +#include #endif // TORRENT_DEBUG && !TORRENT_DISABLE_INVARIANT_CHECKS #include @@ -4814,7 +4810,6 @@ namespace aux { } #endif -#if TORRENT_HAS_BOOST_UNORDERED sha1_hash next_lsd(0); sha1_hash next_dht(0); if (m_next_lsd_torrent != m_torrents.end()) @@ -4824,7 +4819,6 @@ namespace aux { next_dht = m_next_dht_torrent->first; #endif float load_factor = m_torrents.load_factor(); -#endif // TORRENT_HAS_BOOST_UNORDERED m_torrents.insert(std::make_pair(*ih, torrent_ptr)); @@ -4845,7 +4839,6 @@ namespace aux { bump_torrent(torrent_ptr.get()); } -#if TORRENT_HAS_BOOST_UNORDERED // if this insert made the hash grow, the iterators became invalid // we need to reset them if (m_torrents.load_factor() < load_factor) @@ -4858,7 +4851,6 @@ namespace aux { m_next_dht_torrent = m_torrents.find(next_dht); #endif } -#endif // TORRENT_HAS_BOOST_UNORDERED #ifndef TORRENT_NO_DEPRECATE //deprecated in 1.2 @@ -6809,11 +6801,7 @@ namespace aux { } } -#if TORRENT_HAS_BOOST_UNORDERED - boost::unordered_set unique_torrents; -#else - std::set unique_torrents; -#endif + std::unordered_set unique_torrents; for (list_iterator i = m_torrent_lru.iterate(); i.get(); i.next()) { torrent* t = i.get(); @@ -6828,11 +6816,7 @@ namespace aux { #if defined TORRENT_EXPENSIVE_INVARIANT_CHECKS -#if TORRENT_HAS_BOOST_UNORDERED - boost::unordered_set unique; -#else - std::set unique; -#endif + std::unordered_set unique; #endif int num_active_downloading = 0; @@ -6873,11 +6857,7 @@ namespace aux { TORRENT_ASSERT(num_active_downloading == m_torrent_lists[torrent_want_peers_download].size()); TORRENT_ASSERT(num_active_finished == m_torrent_lists[torrent_want_peers_finished].size()); -#if TORRENT_HAS_BOOST_UNORDERED - boost::unordered_set unique_peers; -#else - std::set unique_peers; -#endif + std::unordered_set unique_peers; TORRENT_ASSERT(m_settings.get_int(settings_pack::connections_limit) > 0); int unchokes = 0; diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index fa1c9aafb..dca6b1e2c 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -58,8 +58,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include +#include #include #include #include @@ -520,7 +520,6 @@ namespace libtorrent return true; } -#if TORRENT_HAS_BOOST_UNORDERED struct string_hash_no_case { size_t operator()(std::string const& s) const @@ -561,29 +560,6 @@ namespace libtorrent } }; -#else - struct string_less_no_case - { - bool operator()(std::string const& lhs, std::string const& rhs) const - { - char c1, c2; - char const* s1 = lhs.c_str(); - char const* s2 = rhs.c_str(); - - while (*s1 != 0 || *s2 != 0) - { - c1 = to_lower(*s1); - c2 = to_lower(*s2); - if (c1 < c2) return true; - if (c1 > c2) return false; - ++s1; - ++s2; - } - return false; - } - }; -#endif - // root_dir is the name of the torrent, unless this is a single file // torrent, in which case it's empty. bool extract_files(bdecode_node const& list, file_storage& target @@ -697,7 +673,7 @@ namespace libtorrent { INVARIANT_CHECK; - boost::unordered_set files; + std::unordered_set files; std::string empty_str; @@ -725,11 +701,7 @@ namespace libtorrent INVARIANT_CHECK; int cnt = 0; -#if TORRENT_HAS_BOOST_UNORDERED - boost::unordered_set files; -#else - std::set files; -#endif + std::unordered_set files; std::vector const& paths = m_files.paths(); files.reserve(paths.size() + m_files.num_files());