diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-06-06 15:05:16 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-06-06 15:05:38 +0200 |
commit | 0fbe22a77289a624e1346ab457734c2f64f8e6fb (patch) | |
tree | 16388b26e4eeb464add07c173fbc89995f393387 /include/com | |
parent | 1bf3cafd4cd6c3133adaad764e4f216a5d0ead1c (diff) |
css::uno::Any move semantics (for LIBO_INTERNAL_ONLY)
Change-Id: Ib582a744321e0f209395651ac2edffe30152ffba
Diffstat (limited to 'include/com')
-rw-r--r-- | include/com/sun/star/uno/Any.h | 5 | ||||
-rw-r--r-- | include/com/sun/star/uno/Any.hxx | 33 |
2 files changed, 38 insertions, 0 deletions
diff --git a/include/com/sun/star/uno/Any.h b/include/com/sun/star/uno/Any.h index 26127f4add37..d6c7477d3f4c 100644 --- a/include/com/sun/star/uno/Any.h +++ b/include/com/sun/star/uno/Any.h @@ -135,6 +135,11 @@ public: */ 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. @return a Type object of the set value diff --git a/include/com/sun/star/uno/Any.hxx b/include/com/sun/star/uno/Any.hxx index 8859fa76809b..1e1f24e85fc8 100644 --- a/include/com/sun/star/uno/Any.hxx +++ b/include/com/sun/star/uno/Any.hxx @@ -21,6 +21,7 @@ #include <sal/config.h> +#include <algorithm> #include <cassert> #include <cstddef> #include <iomanip> @@ -120,6 +121,38 @@ inline Any & Any::operator = ( const Any & rAny ) 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 { return ::rtl::OUString( pType->pTypeName ); |