summaryrefslogtreecommitdiff
path: root/include/com/sun/star/uno/Reference.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/com/sun/star/uno/Reference.h')
-rw-r--r--include/com/sun/star/uno/Reference.h53
1 files changed, 7 insertions, 46 deletions
diff --git a/include/com/sun/star/uno/Reference.h b/include/com/sun/star/uno/Reference.h
index 951902b356bd..0221f0ca5f54 100644
--- a/include/com/sun/star/uno/Reference.h
+++ b/include/com/sun/star/uno/Reference.h
@@ -24,6 +24,10 @@
#include <cassert>
#include <cstddef>
+#if defined LIBO_INTERNAL_ONLY
+#include <type_traits>
+#endif
+
#include "rtl/alloc.h"
namespace com
@@ -167,51 +171,6 @@ enum UnoReference_SetThrow
UNO_SET_THROW
};
-#if defined LIBO_INTERNAL_ONLY
-/// @cond INTERNAL
-namespace detail {
-
-// A mechanism to enable up-casts, used by the Reference conversion constructor,
-// but at the same time disable up-casts to XInterface, so that the conversion
-// operator for that special case is used in an expression like
-// Reference< XInterface >(x); heavily borrowed from boost::is_base_and_derived
-// (which manages to avoid compilation problems with ambiguous bases and cites
-// comp.lang.c++.moderated mail <http://groups.google.com/groups?
-// 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 (basing on C++11 std::is_base_of does not work when the types are
-// incomplete):
-
-template< typename T1, typename T2 > struct UpCast {
-private:
- template< bool, typename U1, typename > struct C
- { typedef U1 t; };
-
- template< typename U1, typename U2 > struct C< false, U1, U2 >
- { typedef U2 t; };
-
- struct S { char c[2]; };
-
- template< typename U > static char f(T2 *, U);
- static S f(T1 *, int);
-
- struct H {
- H(); // avoid C2514 "class has no constructors" from MSVC
- operator T1 * () const;
- operator T2 * ();
- };
-
-public:
- typedef typename C< sizeof (f(H(), 0)) == 1, void *, void >::t t;
-};
-
-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
for reference type.
@@ -314,7 +273,9 @@ public:
template< class derived_type >
inline Reference(
const Reference< derived_type > & rRef,
- typename detail::UpCast< interface_type, derived_type >::t = 0 );
+ std::enable_if_t<
+ std::is_base_of_v<interface_type, derived_type>
+ && !std::is_same_v<interface_type, XInterface>, void *> = nullptr);
#endif
/** Constructor: Sets given interface pointer.