summaryrefslogtreecommitdiffstats
path: root/include/rtl/ref.hxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-22 13:36:13 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-24 18:26:23 +0200
commitb95ead7b2a39bf52e2293d7e8094b9520af74ade (patch)
treee57a6846e28cc5cd63837448ac86dbf833dfe77f /include/rtl/ref.hxx
parentremove unwanted commented out hunk (diff)
downloadcore-b95ead7b2a39bf52e2293d7e8094b9520af74ade.tar.gz
core-b95ead7b2a39bf52e2293d7e8094b9520af74ade.zip
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@collabora.co.uk>
Diffstat (limited to 'include/rtl/ref.hxx')
-rw-r--r--include/rtl/ref.hxx21
1 files changed, 21 insertions, 0 deletions
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