OwnPtr: Use copy/move-and-swap for assignment operators

https://bugs.webkit.org/show_bug.cgi?id=121154

Reviewed by Anders Carlsson.

Rationals:
- decrease of repeated code
- consistency with RefPtr

* wtf/OwnPtr.h:
(WTF::=):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155526 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 19de023d
2013-09-11 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
OwnPtr: Use copy/move-and-swap for assignment operators
https://bugs.webkit.org/show_bug.cgi?id=121154
Reviewed by Anders Carlsson.
Rationals:
- decrease of repeated code
- consistency with RefPtr
* wtf/OwnPtr.h:
(WTF::=):
2013-09-11 Patrick Gansterer <paroga@webkit.org>
[CMake] Split out generic Windows files into its own file
......
......@@ -164,21 +164,17 @@ namespace WTF {
template<typename T> inline OwnPtr<T>& OwnPtr<T>::operator=(OwnPtr<T>&& o)
{
PtrType ptr = m_ptr;
m_ptr = o.leakPtr();
ASSERT(!ptr || m_ptr != ptr);
deleteOwnedPtr(ptr);
ASSERT(!o || o != m_ptr);
auto ptr = std::move(o);
swap(ptr);
return *this;
}
template<typename T> template<typename U> inline OwnPtr<T>& OwnPtr<T>::operator=(OwnPtr<U>&& o)
{
PtrType ptr = m_ptr;
m_ptr = o.leakPtr();
ASSERT(!ptr || m_ptr != ptr);
deleteOwnedPtr(ptr);
ASSERT(!o || o != m_ptr);
auto ptr = std::move(o);
swap(ptr);
return *this;
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment