diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index f878af864..09db2d613 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -89,8 +89,7 @@ namespace libtorrent { // data for the torrent. For more information, see the ``storage`` field. explicit add_torrent_params(storage_constructor_type sc = default_storage_constructor); add_torrent_params(add_torrent_params&&) noexcept; - // TODO: GCC did not make std::string nothrow move-assignable - add_torrent_params& operator=(add_torrent_params&&); + add_torrent_params& operator=(add_torrent_params&&) = default; add_torrent_params(add_torrent_params const&); add_torrent_params& operator=(add_torrent_params const&); diff --git a/include/libtorrent/aux_/noexcept_movable.hpp b/include/libtorrent/aux_/noexcept_movable.hpp index 283990c8d..4d25c93db 100644 --- a/include/libtorrent/aux_/noexcept_movable.hpp +++ b/include/libtorrent/aux_/noexcept_movable.hpp @@ -44,26 +44,15 @@ namespace aux { template struct noexcept_movable : T { - noexcept_movable() noexcept(std::is_nothrow_default_constructible::value) {} + noexcept_movable() = default; noexcept_movable(noexcept_movable&& rhs) noexcept : T(std::forward(rhs)) {} - noexcept_movable(noexcept_movable const& rhs) - : T(static_cast(rhs)) - {} + noexcept_movable(noexcept_movable const& rhs) = default; noexcept_movable(T&& rhs) noexcept : T(std::forward(rhs)) {} // NOLINT noexcept_movable(T const& rhs) : T(rhs) {} // NOLINT - noexcept_movable& operator=(noexcept_movable&& rhs) noexcept - { - this->T::operator=(std::forward(rhs)); - return *this; - } - noexcept_movable& operator=(noexcept_movable const& rhs) - { - this->T::operator=(rhs); - return *this; - } - + noexcept_movable& operator=(noexcept_movable const& rhs) = default; + noexcept_movable& operator=(noexcept_movable&& rhs) = default; using T::T; using T::operator=; }; diff --git a/include/libtorrent/bdecode.hpp b/include/libtorrent/bdecode.hpp index 984e5b804..2ddc85a51 100644 --- a/include/libtorrent/bdecode.hpp +++ b/include/libtorrent/bdecode.hpp @@ -258,14 +258,14 @@ struct TORRENT_EXPORT bdecode_node , error_code& ec, int* error_pos, int depth_limit, int token_limit); // creates a default constructed node, it will have the type ``none_t``. - bdecode_node(); + bdecode_node() = default; // For owning nodes, the copy will create a copy of the tree, but the // underlying buffer remains the same. bdecode_node(bdecode_node const&); bdecode_node& operator=(bdecode_node const&); bdecode_node(bdecode_node&&) noexcept; - bdecode_node& operator=(bdecode_node&&) noexcept; + bdecode_node& operator=(bdecode_node&&) = default; // the types of bdecoded nodes enum type_t @@ -377,25 +377,25 @@ private: // this points to the root nodes token vector // for the root node, this points to its own m_tokens member - detail::bdecode_token const* m_root_tokens; + detail::bdecode_token const* m_root_tokens = nullptr; // this points to the original buffer that was parsed - char const* m_buffer; - int m_buffer_size; + char const* m_buffer = nullptr; + int m_buffer_size = 0; // this is the index into m_root_tokens that this node refers to // for the root node, it's 0. -1 means uninitialized. - int m_token_idx; + int m_token_idx = -1; // this is a cache of the last element index looked up. This only applies // to lists and dictionaries. If the next lookup is at m_last_index or // greater, we can start iterating the tokens at m_last_token. - mutable int m_last_index; - mutable int m_last_token; + mutable int m_last_index = -1; + mutable int m_last_token = -1; // the number of elements in this list or dict (computed on the first // call to dict_size() or list_size()) - mutable int m_size; + mutable int m_size = -1; }; // print the bencoded structure in a human-readable format to a string @@ -430,10 +430,10 @@ TORRENT_EXPORT std::string print_entry(bdecode_node const& e // simply produces references back into it. TORRENT_EXPORT int bdecode(char const* start, char const* end, bdecode_node& ret , error_code& ec, int* error_pos = nullptr, int depth_limit = 100 - , int token_limit = 1000000); + , int token_limit = 2000000); TORRENT_EXPORT bdecode_node bdecode(span buffer , error_code& ec, int* error_pos = nullptr, int depth_limit = 100 - , int token_limit = 1000000); + , int token_limit = 2000000); } diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index 563ec63f3..cc10f2373 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -45,7 +45,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/sha1_hash.hpp" #include "libtorrent/string_view.hpp" #include "libtorrent/aux_/vector.hpp" -#include "libtorrent/aux_/noexcept_movable.hpp" #include "libtorrent/flags.hpp" namespace libtorrent { @@ -211,7 +210,7 @@ namespace libtorrent { file_storage(file_storage const&); file_storage& operator=(file_storage const&); file_storage(file_storage&&) noexcept; - file_storage& operator=(file_storage&&) noexcept; + file_storage& operator=(file_storage&&) = default; // returns true if the piece length has been initialized // on the file_storage. This is typically taken as a proxy @@ -593,7 +592,7 @@ namespace libtorrent { // name of torrent. For multi-file torrents // this is always the root directory - aux::noexcept_movable m_name; + std::string m_name; // the sum of all file sizes std::int64_t m_total_size; diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index ce2ad6b68..ec96fbfd9 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -282,7 +282,7 @@ namespace aux { // constructs a torrent handle that does not refer to a torrent. // i.e. is_valid() will return false. - torrent_handle() noexcept {} + torrent_handle() noexcept = default; torrent_handle(torrent_handle const& t) = default; torrent_handle(torrent_handle&& t) noexcept = default; diff --git a/include/libtorrent/torrent_status.hpp b/include/libtorrent/torrent_status.hpp index f94bafe48..ce0e05f3c 100644 --- a/include/libtorrent/torrent_status.hpp +++ b/include/libtorrent/torrent_status.hpp @@ -58,8 +58,6 @@ namespace libtorrent { torrent_status(torrent_status const&); torrent_status& operator=(torrent_status const&); torrent_status(torrent_status&&) noexcept; - // TODO: 2 msvc and GCC did not make std::string nothrow move-assignable - // until C++17 torrent_status& operator=(torrent_status&&); // compares if the torrent status objects come from the same torrent. i.e. diff --git a/src/add_torrent_params.cpp b/src/add_torrent_params.cpp index e213ab01e..5953fd339 100644 --- a/src/add_torrent_params.cpp +++ b/src/add_torrent_params.cpp @@ -37,7 +37,6 @@ namespace libtorrent { add_torrent_params::add_torrent_params(storage_constructor_type sc) : storage(std::move(sc)) {} add_torrent_params::add_torrent_params(add_torrent_params&&) noexcept = default; - add_torrent_params& add_torrent_params::operator=(add_torrent_params&&) = default; add_torrent_params::add_torrent_params(add_torrent_params const&) = default; add_torrent_params& add_torrent_params::operator=(add_torrent_params const&) = default; diff --git a/src/bdecode.cpp b/src/bdecode.cpp index 7fcb51e44..57278b6bd 100644 --- a/src/bdecode.cpp +++ b/src/bdecode.cpp @@ -202,16 +202,6 @@ namespace { } } - bdecode_node::bdecode_node() - : m_root_tokens(nullptr) - , m_buffer(nullptr) - , m_buffer_size(0) - , m_token_idx(-1) - , m_last_index(-1) - , m_last_token(-1) - , m_size(-1) - {} - bdecode_node::bdecode_node(bdecode_node const& n) : m_tokens(n.m_tokens) , m_root_tokens(n.m_root_tokens) @@ -246,7 +236,6 @@ namespace { } bdecode_node::bdecode_node(bdecode_node&&) noexcept = default; - bdecode_node& bdecode_node::operator=(bdecode_node&&) noexcept = default; bdecode_node::bdecode_node(bdecode_token const* tokens, char const* buf , int len, int idx) diff --git a/src/file_storage.cpp b/src/file_storage.cpp index a23cdf937..6af673c14 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -81,7 +81,6 @@ namespace libtorrent { file_storage::file_storage(file_storage const&) = default; file_storage& file_storage::operator=(file_storage const&) = default; file_storage::file_storage(file_storage&&) noexcept = default; - file_storage& file_storage::operator=(file_storage&&) noexcept = default; void file_storage::reserve(int num_files) { diff --git a/src/torrent_status.cpp b/src/torrent_status.cpp index ecef3831e..80c8976d1 100644 --- a/src/torrent_status.cpp +++ b/src/torrent_status.cpp @@ -49,8 +49,6 @@ namespace libtorrent { static_assert(std::is_nothrow_move_constructible::value , "should be nothrow move constructible"); -// static_assert(std::is_nothrow_move_assignable::value -// , "should be nothrow move assignable"); static_assert(std::is_nothrow_default_constructible::value , "should be nothrow default constructible"); }