forked from premiere/premiere-libtorrent
qualify some assignment operators to disallow assignment to temporaries
This commit is contained in:
parent
2c5da2778a
commit
d439c8729a
|
@ -14,7 +14,7 @@ struct bytes
|
|||
bytes(std::string&& s): arr(std::move(s)) {}
|
||||
bytes(bytes const&) = default;
|
||||
bytes(bytes&&) noexcept = default;
|
||||
bytes& operator=(bytes&&) noexcept = default;
|
||||
bytes& operator=(bytes&&) & noexcept = default;
|
||||
bytes() {}
|
||||
std::string arr;
|
||||
};
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace libtorrent { namespace aux {
|
|||
crypt_hash(crypt_hash const& h) { m_hash = duplicate(h); }
|
||||
~crypt_hash() { CryptDestroyHash(m_hash); }
|
||||
|
||||
crypt_hash& crypt_hash::operator=(crypt_hash const& h)
|
||||
crypt_hash& crypt_hash::operator=(crypt_hash const& h) &
|
||||
{
|
||||
if (this == &h) return *this;
|
||||
HCRYPTHASH temp = duplicate(h);
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace libtorrent {
|
|||
used_size = rhs.used_size;
|
||||
move_holder(&holder, &rhs.holder);
|
||||
}
|
||||
buffer_t& operator=(buffer_t&& rhs) noexcept
|
||||
buffer_t& operator=(buffer_t&& rhs) & noexcept
|
||||
{
|
||||
destruct_holder(&holder);
|
||||
destruct_holder = rhs.destruct_holder;
|
||||
|
@ -99,7 +99,7 @@ namespace libtorrent {
|
|||
}
|
||||
buffer_t(buffer_t const& rhs) noexcept
|
||||
: buffer_t(std::move(const_cast<buffer_t&>(rhs))) {}
|
||||
buffer_t& operator=(buffer_t const& rhs) noexcept
|
||||
buffer_t& operator=(buffer_t const& rhs) & noexcept
|
||||
{ return this->operator=(std::move(const_cast<buffer_t&>(rhs))); }
|
||||
#else
|
||||
buffer_t(buffer_t&&) = delete;
|
||||
|
|
|
@ -46,13 +46,13 @@ namespace libtorrent {
|
|||
copy_ptr(copy_ptr&& p) noexcept = default;
|
||||
|
||||
void reset(T* t = nullptr) { m_ptr.reset(t); }
|
||||
copy_ptr& operator=(copy_ptr const& p)
|
||||
copy_ptr& operator=(copy_ptr const& p) &
|
||||
{
|
||||
if (m_ptr == p.m_ptr) return *this;
|
||||
m_ptr.reset(p.m_ptr ? new T(*p.m_ptr) : nullptr);
|
||||
return *this;
|
||||
}
|
||||
copy_ptr& operator=(copy_ptr&& p) noexcept = default;
|
||||
copy_ptr& operator=(copy_ptr&& p) & noexcept = default;
|
||||
T* operator->() { return m_ptr.get(); }
|
||||
T const* operator->() const { return m_ptr.get(); }
|
||||
T& operator*() { return *m_ptr; }
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace libtorrent {
|
|||
disk_buffer_holder(buffer_allocator_interface& alloc
|
||||
, char* buf, std::size_t sz) noexcept;
|
||||
|
||||
disk_buffer_holder& operator=(disk_buffer_holder&&) noexcept;
|
||||
disk_buffer_holder& operator=(disk_buffer_holder&&) & noexcept;
|
||||
disk_buffer_holder(disk_buffer_holder&&) noexcept;
|
||||
|
||||
disk_buffer_holder& operator=(disk_buffer_holder const&) = delete;
|
||||
|
|
|
@ -191,17 +191,17 @@ namespace aux {
|
|||
// copies the structure of the right hand side into this
|
||||
// entry.
|
||||
#if TORRENT_ABI_VERSION == 1
|
||||
entry& operator=(lazy_entry const&);
|
||||
entry& operator=(lazy_entry const&) &;
|
||||
#endif
|
||||
entry& operator=(bdecode_node const&);
|
||||
entry& operator=(entry const&);
|
||||
entry& operator=(entry&&) noexcept;
|
||||
entry& operator=(dictionary_type);
|
||||
entry& operator=(span<char const>);
|
||||
entry& operator=(bdecode_node const&) &;
|
||||
entry& operator=(entry const&) &;
|
||||
entry& operator=(entry&&) & noexcept;
|
||||
entry& operator=(dictionary_type) &;
|
||||
entry& operator=(span<char const>) &;
|
||||
template <typename U, typename Cond = typename std::enable_if<
|
||||
std::is_same<U, entry::string_type>::value
|
||||
|| std::is_same<U, char const*>::value>::type>
|
||||
entry& operator=(U v)
|
||||
entry& operator=(U v) &
|
||||
{
|
||||
destruct();
|
||||
new(&data) string_type(std::move(v));
|
||||
|
@ -211,9 +211,9 @@ namespace aux {
|
|||
#endif
|
||||
return *this;
|
||||
}
|
||||
entry& operator=(list_type);
|
||||
entry& operator=(integer_type);
|
||||
entry& operator=(preformatted_type);
|
||||
entry& operator=(list_type) &;
|
||||
entry& operator=(integer_type) &;
|
||||
entry& operator=(preformatted_type) &;
|
||||
|
||||
// The ``integer()``, ``string()``, ``list()`` and ``dict()`` functions
|
||||
// are accessors that return the respective type. If the ``entry`` object
|
||||
|
|
|
@ -59,9 +59,9 @@ namespace libtorrent {
|
|||
// hidden
|
||||
~file_entry();
|
||||
file_entry(file_entry const&) = default;
|
||||
file_entry& operator=(file_entry const&) = default;
|
||||
file_entry& operator=(file_entry const&) & = default;
|
||||
file_entry(file_entry&&) noexcept = default;
|
||||
file_entry& operator=(file_entry&&) noexcept = default;
|
||||
file_entry& operator=(file_entry&&) & noexcept = default;
|
||||
|
||||
// the full path of this file. The paths are unicode strings
|
||||
// encoded in UTF-8.
|
||||
|
@ -117,9 +117,9 @@ namespace libtorrent {
|
|||
|
||||
internal_file_entry();
|
||||
internal_file_entry(internal_file_entry const& fe);
|
||||
internal_file_entry& operator=(internal_file_entry const& fe);
|
||||
internal_file_entry& operator=(internal_file_entry const& fe) &;
|
||||
internal_file_entry(internal_file_entry&& fe) noexcept;
|
||||
internal_file_entry& operator=(internal_file_entry&& fe) noexcept;
|
||||
internal_file_entry& operator=(internal_file_entry&& fe) & noexcept;
|
||||
~internal_file_entry();
|
||||
|
||||
void set_name(char const* n, bool borrow_string = false, int string_len = 0);
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace libtorrent {
|
|||
hasher(char const* data, int len);
|
||||
explicit hasher(span<char const> data);
|
||||
hasher(hasher const&);
|
||||
hasher& operator=(hasher const&);
|
||||
hasher& operator=(hasher const&) &;
|
||||
|
||||
// append the following bytes to what is being hashed
|
||||
hasher& update(span<char const> data);
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace libtorrent {
|
|||
// ``update(data)``.
|
||||
explicit hasher512(span<char const> data);
|
||||
hasher512(hasher512 const&);
|
||||
hasher512& operator=(hasher512 const&);
|
||||
hasher512& operator=(hasher512 const&) &;
|
||||
|
||||
// append the following bytes to what is being hashed
|
||||
hasher512& update(span<char const> data);
|
||||
|
|
|
@ -44,7 +44,7 @@ TORRENT_IPV6_NAMESPACE
|
|||
{
|
||||
union_address() { *this = address(); }
|
||||
explicit union_address(address const& a) { *this = a; }
|
||||
union_address& operator=(address const& a)
|
||||
union_address& operator=(address const& a) &
|
||||
{
|
||||
#if TORRENT_USE_IPV6
|
||||
v4 = a.is_v4();
|
||||
|
@ -104,7 +104,7 @@ TORRENT_IPV6_NAMESPACE
|
|||
explicit union_endpoint(udp::endpoint const& ep) { *this = ep; }
|
||||
union_endpoint() { *this = tcp::endpoint(); }
|
||||
|
||||
union_endpoint& operator=(udp::endpoint const& ep)
|
||||
union_endpoint& operator=(udp::endpoint const& ep) &
|
||||
{
|
||||
addr = ep.address();
|
||||
port = ep.port();
|
||||
|
@ -113,7 +113,7 @@ TORRENT_IPV6_NAMESPACE
|
|||
|
||||
operator udp::endpoint() const { return udp::endpoint(addr, port); }
|
||||
|
||||
union_endpoint& operator=(tcp::endpoint const& ep)
|
||||
union_endpoint& operator=(tcp::endpoint const& ep) &
|
||||
{
|
||||
addr = ep.address();
|
||||
port = ep.port();
|
||||
|
|
|
@ -88,8 +88,8 @@ namespace libtorrent { namespace aux {
|
|||
strong_typedef& operator-=(diff_type rhs)
|
||||
{ m_val -= static_cast<UnderlyingType>(rhs); return *this; }
|
||||
|
||||
strong_typedef& operator=(strong_typedef const& rhs) noexcept = default;
|
||||
strong_typedef& operator=(strong_typedef&& rhs) noexcept = default;
|
||||
strong_typedef& operator=(strong_typedef const& rhs) & noexcept = default;
|
||||
strong_typedef& operator=(strong_typedef&& rhs) & noexcept = default;
|
||||
private:
|
||||
UnderlyingType m_val;
|
||||
};
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace libtorrent {
|
|||
: m_allocator(&alloc), m_buf(buf), m_size(sz), m_ref()
|
||||
{}
|
||||
|
||||
disk_buffer_holder& disk_buffer_holder::operator=(disk_buffer_holder&& h) noexcept
|
||||
disk_buffer_holder& disk_buffer_holder::operator=(disk_buffer_holder&& h) & noexcept
|
||||
{
|
||||
if (&h == this) return *this;
|
||||
disk_buffer_holder(std::move(h)).swap(*this);
|
||||
|
|
|
@ -132,7 +132,7 @@ namespace {
|
|||
|
||||
entry::~entry() { destruct(); }
|
||||
|
||||
entry& entry::operator=(const entry& e)
|
||||
entry& entry::operator=(const entry& e) &
|
||||
{
|
||||
if (&e == this) return *this;
|
||||
destruct();
|
||||
|
@ -140,7 +140,7 @@ namespace {
|
|||
return *this;
|
||||
}
|
||||
|
||||
entry& entry::operator=(entry&& e) noexcept
|
||||
entry& entry::operator=(entry&& e) & noexcept
|
||||
{
|
||||
if (&e == this) return *this;
|
||||
destruct();
|
||||
|
@ -360,7 +360,7 @@ namespace {
|
|||
}
|
||||
|
||||
// convert a bdecode_node into an old skool entry
|
||||
entry& entry::operator=(bdecode_node const& e)
|
||||
entry& entry::operator=(bdecode_node const& e) &
|
||||
{
|
||||
switch (e.type())
|
||||
{
|
||||
|
@ -399,7 +399,7 @@ namespace {
|
|||
|
||||
#if TORRENT_ABI_VERSION == 1
|
||||
// convert a lazy_entry into an old skool entry
|
||||
entry& entry::operator=(lazy_entry const& e)
|
||||
entry& entry::operator=(lazy_entry const& e) &
|
||||
{
|
||||
switch (e.type())
|
||||
{
|
||||
|
@ -437,7 +437,7 @@ namespace {
|
|||
}
|
||||
#endif
|
||||
|
||||
entry& entry::operator=(preformatted_type v)
|
||||
entry& entry::operator=(preformatted_type v) &
|
||||
{
|
||||
destruct();
|
||||
new(&data) preformatted_type(std::move(v));
|
||||
|
@ -448,7 +448,7 @@ namespace {
|
|||
return *this;
|
||||
}
|
||||
|
||||
entry& entry::operator=(dictionary_type v)
|
||||
entry& entry::operator=(dictionary_type v) &
|
||||
{
|
||||
destruct();
|
||||
new(&data) dictionary_type(std::move(v));
|
||||
|
@ -459,7 +459,7 @@ namespace {
|
|||
return *this;
|
||||
}
|
||||
|
||||
entry& entry::operator=(span<char const> v)
|
||||
entry& entry::operator=(span<char const> v) &
|
||||
{
|
||||
destruct();
|
||||
new(&data) string_type(v.data(), v.size());
|
||||
|
@ -470,7 +470,7 @@ namespace {
|
|||
return *this;
|
||||
}
|
||||
|
||||
entry& entry::operator=(list_type v)
|
||||
entry& entry::operator=(list_type v) &
|
||||
{
|
||||
destruct();
|
||||
new(&data) list_type(std::move(v));
|
||||
|
@ -481,7 +481,7 @@ namespace {
|
|||
return *this;
|
||||
}
|
||||
|
||||
entry& entry::operator=(integer_type v)
|
||||
entry& entry::operator=(integer_type v) &
|
||||
{
|
||||
destruct();
|
||||
new(&data) integer_type(std::move(v));
|
||||
|
|
|
@ -241,7 +241,7 @@ namespace {
|
|||
name = fe.name;
|
||||
}
|
||||
|
||||
internal_file_entry& internal_file_entry::operator=(internal_file_entry const& fe)
|
||||
internal_file_entry& internal_file_entry::operator=(internal_file_entry const& fe) &
|
||||
{
|
||||
if (&fe == this) return *this;
|
||||
offset = fe.offset;
|
||||
|
@ -274,7 +274,7 @@ namespace {
|
|||
fe.name = nullptr;
|
||||
}
|
||||
|
||||
internal_file_entry& internal_file_entry::operator=(internal_file_entry&& fe) noexcept
|
||||
internal_file_entry& internal_file_entry::operator=(internal_file_entry&& fe) & noexcept
|
||||
{
|
||||
if (&fe == this) return *this;
|
||||
offset = fe.offset;
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace libtorrent {
|
|||
gcry_md_copy(&m_context, h.m_context);
|
||||
}
|
||||
|
||||
hasher& hasher::operator=(hasher const& h)
|
||||
hasher& hasher::operator=(hasher const& h) &
|
||||
{
|
||||
if (this == &h) return;
|
||||
gcry_md_close(m_context);
|
||||
|
@ -84,7 +84,7 @@ namespace libtorrent {
|
|||
}
|
||||
#else
|
||||
hasher::hasher(hasher const&) = default;
|
||||
hasher& hasher::operator=(hasher const&) = default;
|
||||
hasher& hasher::operator=(hasher const&) & = default;
|
||||
#endif
|
||||
|
||||
hasher& hasher::update(char const* data, int len)
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace libtorrent {
|
|||
gcry_md_copy(&m_context, h.m_context);
|
||||
}
|
||||
|
||||
hasher512& hasher512::operator=(hasher512 const& h)
|
||||
hasher512& hasher512::operator=(hasher512 const& h) &
|
||||
{
|
||||
if (this == &h) return;
|
||||
gcry_md_close(m_context);
|
||||
|
@ -77,7 +77,7 @@ namespace libtorrent {
|
|||
}
|
||||
#else
|
||||
hasher512::hasher512(hasher512 const&) = default;
|
||||
hasher512& hasher512::operator=(hasher512 const&) = default;
|
||||
hasher512& hasher512::operator=(hasher512 const&) & = default;
|
||||
#endif
|
||||
|
||||
hasher512& hasher512::update(span<char const> data)
|
||||
|
|
Loading…
Reference in New Issue