summaryrefslogtreecommitdiffstats
path: root/include/com
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-04-23 20:21:20 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-04-23 21:50:20 +0200
commit39a1edd6fec902ef378acce8af42c4d7fba280d0 (patch)
tree6864738c0c7280d5bcd3c10b32ff88d2fe0d3e89 /include/com
parentDon't call default ctor only to reassign later (diff)
downloadcore-39a1edd6fec902ef378acce8af42c4d7fba280d0.tar.gz
core-39a1edd6fec902ef378acce8af42c4d7fba280d0.zip
Make css::uno::Reference upcast ctor LIBO_INTERNAL_ONLY
It looks like an oversight that 904b3d1fceee5827076758ed2a81f80cb73493ca "Up- cast conversion constructor for css::uno::Reference" added it also for external code. Making it LIBO_INTERNAL_ONLY allows to remove workarounds for old MSVC, and may allow to simplify the code further in the future. (Though using std::is_base_of, as suggested in the comment, is not easily possible, as it would cause errors like > include/c++/v1/type_traits:1726:59: error: incomplete type 'com::sun::star::lang::XMultiServiceFactory' used in type trait expression > : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; > ^ > include/c++/v1/type_traits:1731:7: note: in instantiation of template class 'std::__1::is_base_of<com::sun::star::beans::XPropertySet, com::sun::star::lang::XMultiServiceFactory>' requested here > = is_base_of<_Bp, _Dp>::value; > ^ > include/com/sun/star/uno/Reference.h:277:18: note: in instantiation of variable template specialization 'std::__1::is_base_of_v<com::sun::star::beans::XPropertySet, com::sun::star::lang::XMultiServiceFactory>' requested here > std::is_base_of_v<interface_type, derived_type> > ^ > ucbhelper/source/provider/getcomponentcontext.cxx:34:9: note: while substituting deduced template arguments into function template 'Reference' [with derived_type = com::sun::star::lang::XMultiServiceFactory] > css::uno::Reference< css::beans::XPropertySet >( > ^ > include/ucbhelper/getcomponentcontext.hxx:29:28: note: forward declaration of 'com::sun::star::lang::XMultiServiceFactory' > namespace lang { class XMultiServiceFactory; } > ^ with incomplete types.) Change-Id: I6da3395df904797cec83c1f6ab24b386527d4cea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92802 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/com')
-rw-r--r--include/com/sun/star/uno/Reference.h16
-rw-r--r--include/com/sun/star/uno/Reference.hxx2
2 files changed, 6 insertions, 12 deletions
diff --git a/include/com/sun/star/uno/Reference.h b/include/com/sun/star/uno/Reference.h
index 50afd26a83b4..951902b356bd 100644
--- a/include/com/sun/star/uno/Reference.h
+++ b/include/com/sun/star/uno/Reference.h
@@ -167,6 +167,7 @@ enum UnoReference_SetThrow
UNO_SET_THROW
};
+#if defined LIBO_INTERNAL_ONLY
/// @cond INTERNAL
namespace detail {
@@ -179,7 +180,8 @@ namespace detail {
// selm=df893da6.0301280859.522081f7%40posting.google.com> "SuperSubclass
// (is_base_and_derived) complete implementation!" by Rani Sharoni and cites
// Aleksey Gurtovoy for the workaround for MSVC), to avoid including Boost
-// headers in URE headers (could ultimately be based on C++11 std::is_base_of):
+// headers in URE headers (basing on C++11 std::is_base_of does not work when the types are
+// incomplete):
template< typename T1, typename T2 > struct UpCast {
private:
@@ -191,21 +193,12 @@ private:
struct S { char c[2]; };
-#if defined _MSC_VER && _MSC_VER < 1800
- static char f(T2 *, long);
- static S f(T1 * const &, int);
-#else
template< typename U > static char f(T2 *, U);
static S f(T1 *, int);
-#endif
struct H {
H(); // avoid C2514 "class has no constructors" from MSVC
-#if defined _MSC_VER && _MSC_VER < 1800
- operator T1 * const & () const;
-#else
operator T1 * () const;
-#endif
operator T2 * ();
};
@@ -217,6 +210,7 @@ template< typename T2 > struct UpCast< XInterface, T2 > {};
}
/// @endcond
+#endif
/** Template reference class for interface type derived from BaseReference.
A special constructor given the UNO_QUERY identifier queries interfaces
@@ -308,7 +302,6 @@ public:
@param rRef another reference
*/
inline Reference( Reference< interface_type > && rRef ) noexcept;
-#endif
/** Up-casting conversion constructor: Copies interface reference.
@@ -322,6 +315,7 @@ public:
inline Reference(
const Reference< derived_type > & rRef,
typename detail::UpCast< interface_type, derived_type >::t = 0 );
+#endif
/** Constructor: Sets given interface pointer.
diff --git a/include/com/sun/star/uno/Reference.hxx b/include/com/sun/star/uno/Reference.hxx
index 9edbd70d0f88..b3c01aaa2391 100644
--- a/include/com/sun/star/uno/Reference.hxx
+++ b/include/com/sun/star/uno/Reference.hxx
@@ -131,7 +131,6 @@ inline Reference< interface_type >::Reference( Reference< interface_type > && rR
_pInterface = rRef._pInterface;
rRef._pInterface = nullptr;
}
-#endif
template< class interface_type > template< class derived_type >
inline Reference< interface_type >::Reference(
@@ -143,6 +142,7 @@ inline Reference< interface_type >::Reference(
if (_pInterface)
_pInterface->acquire();
}
+#endif
template< class interface_type >
inline Reference< interface_type >::Reference( interface_type * pInterface )