From f0f600751feb5615499010c31e5a577568a88e7f Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 20 Sep 2016 11:29:40 +0200 Subject: cid#1371245: Add move semantics Change-Id: I35daf9030478831262521497a1977bdfbe661dd8 --- include/osl/socket.hxx | 16 ++++++++++++++++ include/osl/socket_decl.hxx | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/include/osl/socket.hxx b/include/osl/socket.hxx index b4012cca76f8..190a7d7ea558 100644 --- a/include/osl/socket.hxx +++ b/include/osl/socket.hxx @@ -34,6 +34,11 @@ namespace osl { } +#if defined LIBO_INTERNAL_ONLY + SocketAddr::SocketAddr(SocketAddr && other): m_handle(other.m_handle) { + other.m_handle = nullptr; + } +#endif inline SocketAddr::SocketAddr(oslSocketAddr Addr) : m_handle( osl_copySocketAddr( Addr ) ) @@ -135,6 +140,17 @@ namespace osl return *this; } +#if defined LIBO_INTERNAL_ONLY + SocketAddr & SocketAddr::operator =(SocketAddr && other) { + if (m_handle != nullptr) { + osl_destroySocketAddr(m_handle); + } + m_handle = other.m_handle; + other.m_handle = nullptr; + return *this; + } +#endif + inline SocketAddr & SAL_CALL SocketAddr::assign( oslSocketAddr Addr, __osl_socket_NoCopy ) { if( m_handle ) diff --git a/include/osl/socket_decl.hxx b/include/osl/socket_decl.hxx index 1913956da191..760096bab113 100644 --- a/include/osl/socket_decl.hxx +++ b/include/osl/socket_decl.hxx @@ -50,6 +50,10 @@ namespace osl */ inline SocketAddr(const SocketAddr& Addr); +#if defined LIBO_INTERNAL_ONLY + inline SocketAddr(SocketAddr && other); +#endif + /** The SocketAddr takes over the responsibility of the handle ( which means, that the handle gets destructed by the destructor of this reference) @param Addr a handle @@ -119,6 +123,10 @@ namespace osl */ inline SocketAddr & SAL_CALL operator= (const SocketAddr& Addr); +#if defined LIBO_INTERNAL_ONLY + inline SocketAddr & operator =(SocketAddr && other); +#endif + /** Assigns the socket addr without copyconstructing it. @param Addr the socket address. @param nocopy use SAL_NO_COPY -- cgit