[Libreoffice-commits] core.git: include/rtl

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 24 16:26:59 UTC 2020


 include/rtl/ref.hxx |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

New commits:
commit b95ead7b2a39bf52e2293d7e8094b9520af74ade
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Apr 22 13:36:13 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Apr 24 18:26:23 2020 +0200

    add upcasting support to rtl::Reference
    
    Change-Id: I34ca9ef65356be56db7ac008238ccadc6697e27a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92693
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/rtl/ref.hxx b/include/rtl/ref.hxx
index b0324d99313d..838be87c2c89 100644
--- a/include/rtl/ref.hxx
+++ b/include/rtl/ref.hxx
@@ -25,6 +25,9 @@
 #include <cassert>
 #include <cstddef>
 #include <functional>
+#ifdef LIBO_INTERNAL_ONLY
+#include <type_traits>
+#endif
 
 #include "sal/types.h"
 
@@ -84,6 +87,24 @@ public:
     }
 #endif
 
+#if defined LIBO_INTERNAL_ONLY
+    /** Up-casting conversion constructor: Copies interface reference.
+
+        Does not work for up-casts to ambiguous bases.
+
+        @param rRef another reference
+    */
+    template< class derived_type >
+    inline Reference(
+        const Reference< derived_type > & rRef,
+        std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 )
+        : m_pBody (rRef.get())
+    {
+        if (m_pBody)
+            m_pBody->acquire();
+    }
+#endif
+
     /** Destructor...
      */
     ~Reference() COVERITY_NOEXCEPT_FALSE


More information about the Libreoffice-commits mailing list