Kaydet (Commit) 0fbe22a7 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

css::uno::Any move semantics (for LIBO_INTERNAL_ONLY)

Change-Id: Ib582a744321e0f209395651ac2edffe30152ffba
üst 1bf3cafd
...@@ -135,6 +135,11 @@ public: ...@@ -135,6 +135,11 @@ public:
*/ */
inline Any & SAL_CALL operator = ( const Any & rAny ); inline Any & SAL_CALL operator = ( const Any & rAny );
#if defined LIBO_INTERNAL_ONLY
inline Any(Any && other);
inline Any & operator =(Any && other);
#endif
/** Gets the type of the set value. /** Gets the type of the set value.
@return a Type object of the set value @return a Type object of the set value
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <sal/config.h> #include <sal/config.h>
#include <algorithm>
#include <cassert> #include <cassert>
#include <cstddef> #include <cstddef>
#include <iomanip> #include <iomanip>
...@@ -120,6 +121,38 @@ inline Any & Any::operator = ( const Any & rAny ) ...@@ -120,6 +121,38 @@ inline Any & Any::operator = ( const Any & rAny )
return *this; return *this;
} }
#if defined LIBO_INTERNAL_ONLY
namespace detail {
inline void moveAnyInternals(Any & from, Any & to) {
uno_any_construct(&to, nullptr, nullptr, &cpp_acquire);
std::swap(from.pType, to.pType);
std::swap(from.pData, to.pData);
std::swap(from.pReserved, to.pReserved);
if (to.pData == &from.pReserved) {
to.pData = &to.pReserved;
}
// This leaves to.pData (where "to" is now VOID) dangling to somewhere (cf.
// CONSTRUCT_EMPTY_ANY, cppu/source/uno/prim.hxx), but what's relevant is
// only that it isn't a nullptr (as e.g. >>= -> uno_type_assignData ->
// _assignData takes a null pSource to mean "construct a default value").
}
}
Any::Any(Any && other) {
detail::moveAnyInternals(other, *this);
}
Any & Any::operator =(Any && other) {
uno_any_destruct(this, &cpp_release);
detail::moveAnyInternals(other, *this);
return *this;
}
#endif
inline ::rtl::OUString Any::getValueTypeName() const inline ::rtl::OUString Any::getValueTypeName() const
{ {
return ::rtl::OUString( pType->pTypeName ); return ::rtl::OUString( pType->pTypeName );
......
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