From a0e6b52a3f3481558c69336e0ecef5eb294b9826 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 26 Apr 2015 01:45:23 +0000 Subject: [PATCH] fix msvc build issues --- include/libtorrent/alert.hpp | 4 ++-- include/libtorrent/file_storage.hpp | 10 +++++----- include/libtorrent/torrent.hpp | 2 +- include/libtorrent/torrent_info.hpp | 2 +- src/peer_connection.cpp | 15 ++++++++++++--- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index f0fbe6858..b1ec7b1f8 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -254,10 +254,10 @@ namespace libtorrent { // when the alert queue is full. There are a few alerts which may not be discared, // since they would break the user contract, such as save_resume_data_alert. TORRENT_DEPRECATED - virtual bool discardable() const TORRENT_DEPRECATED { return true; } + virtual bool discardable() const { return true; } TORRENT_DEPRECATED - severity_t severity() const TORRENT_DEPRECATED { return warning; } + severity_t severity() const { return warning; } // returns a pointer to a copy of the alert. virtual std::auto_ptr clone() const = 0; diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index 4b8d09053..f672132ab 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -351,15 +351,15 @@ namespace libtorrent TORRENT_DEPRECATED iterator file_at_offset(boost::int64_t offset) const; TORRENT_DEPRECATED - iterator begin() const TORRENT_DEPRECATED { return m_files.begin(); } + iterator begin() const { return m_files.begin(); } TORRENT_DEPRECATED - iterator end() const TORRENT_DEPRECATED { return m_files.end(); } + iterator end() const { return m_files.end(); } TORRENT_DEPRECATED - reverse_iterator rbegin() const TORRENT_DEPRECATED { return m_files.rbegin(); } + reverse_iterator rbegin() const { return m_files.rbegin(); } TORRENT_DEPRECATED - reverse_iterator rend() const TORRENT_DEPRECATED { return m_files.rend(); } + reverse_iterator rend() const { return m_files.rend(); } TORRENT_DEPRECATED - internal_file_entry const& internal_at(int index) const TORRENT_DEPRECATED + internal_file_entry const& internal_at(int index) const { TORRENT_ASSERT(index >= 0); TORRENT_ASSERT(index < int(m_files.size())); diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 9e7f6ac31..73cc31619 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -988,7 +988,7 @@ namespace libtorrent int num_connect_candidates() const { return m_peer_list ? m_peer_list->num_connect_candidates() : 0; } piece_manager& storage(); - bool has_storage() const { return m_storage; } + bool has_storage() const { return m_storage.get() != NULL; } torrent_info const& torrent_file() const { return *m_torrent_file; } diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 78034b7fe..13e9ed36c 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -187,7 +187,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE // deprecated in 1.0 TORRENT_DEPRECATED - bool will_announce(time_point now) const TORRENT_DEPRECATED + bool will_announce(time_point now) const { return now <= next_announce && (fails < fail_limit || fail_limit == 0) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 87334b118..1852d4533 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2212,9 +2212,12 @@ namespace libtorrent if (t->alerts().should_post()) { + // msvc 12 appears to deduce the rvalue reference template + // incorrectly for bool temporaries. So, create a dummy instance + bool peer_interested = bool(m_peer_interested); t->alerts().emplace_alert( t->get_handle(), m_remote, m_peer_id, r - , t->has_piece_passed(r.piece), bool(m_peer_interested), true); + , t->has_piece_passed(r.piece), peer_interested, true); } return; } @@ -2282,9 +2285,12 @@ namespace libtorrent #endif if (t->alerts().should_post()) { + // msvc 12 appears to deduce the rvalue reference template + // incorrectly for bool temporaries. So, create a dummy instance + bool peer_interested = bool(m_peer_interested); t->alerts().emplace_alert( t->get_handle(), m_remote, m_peer_id, r - , t->has_piece_passed(r.piece), bool(m_peer_interested), false); + , t->has_piece_passed(r.piece), peer_interested, false); } // be lenient and pretend that the peer said it was interested @@ -2325,9 +2331,12 @@ namespace libtorrent if (t->alerts().should_post()) { + // msvc 12 appears to deduce the rvalue reference template + // incorrectly for bool temporaries. So, create a dummy instance + bool peer_interested = bool(m_peer_interested); t->alerts().emplace_alert( t->get_handle(), m_remote, m_peer_id, r - , t->has_piece_passed(r.piece), bool(m_peer_interested), false); + , t->has_piece_passed(r.piece), peer_interested, false); } // every ten invalid request, remind the peer that it's choked