QHash: code tidies
Apply std::exchange. Remove a wrong comment about MultiNode -- the compiler isn't generating any move operations, the move constructor is user-provided and there isn't a move assignment operator... Change-Id: Idd69458c69cc93e4575c119daba564e0046452c1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
9fa848dcaf
commit
9f1e1eb552
@ -185,9 +185,8 @@ struct MultiNode
|
||||
|
||||
MultiNode(MultiNode &&other)
|
||||
: key(other.key),
|
||||
value(other.value)
|
||||
value(qExchange(other.value, nullptr))
|
||||
{
|
||||
other.value = nullptr;
|
||||
}
|
||||
|
||||
MultiNode(const MultiNode &other)
|
||||
@ -217,16 +216,13 @@ struct MultiNode
|
||||
void insertMulti(Args &&... args)
|
||||
{
|
||||
Chain *e = new Chain{ T(std::forward<Args>(args)...), nullptr };
|
||||
e->next = value;
|
||||
value = e;
|
||||
e->next = qExchange(value, e);
|
||||
}
|
||||
template<typename ...Args>
|
||||
void emplaceValue(Args &&... args)
|
||||
{
|
||||
value->value = T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// compiler generated move operators are fine
|
||||
};
|
||||
|
||||
template<typename Node>
|
||||
@ -1212,10 +1208,10 @@ public:
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
QMultiHash(QMultiHash &&other) noexcept : d(other.d), m_size(other.m_size)
|
||||
QMultiHash(QMultiHash &&other) noexcept
|
||||
: d(qExchange(other.d, nullptr)),
|
||||
m_size(qExchange(other.m_size, 0))
|
||||
{
|
||||
other.d = nullptr;
|
||||
other.m_size = 0;
|
||||
}
|
||||
QMultiHash &operator=(QMultiHash &&other) noexcept(std::is_nothrow_destructible<Node>::value)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user