[Libreoffice-commits] core.git: include/com include/rtl include/tools
Noel Grandin
noel.grandin at collabora.co.uk
Thu Jan 26 06:12:22 UTC 2017
include/com/sun/star/uno/Reference.h | 9 +++++++++
include/rtl/ref.hxx | 8 ++++++++
include/tools/ref.hxx | 2 ++
3 files changed, 19 insertions(+)
New commits:
commit 1480a2d05aff1eb6984882aacf39570b6b78a5d5
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed Jan 25 10:42:28 2017 +0200
add 'explicit operator bool' to our reference classes
Change-Id: I91cfbe2646dcc55b98d2b809c49c9ea073f54f58
Reviewed-on: https://gerrit.libreoffice.org/33517
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/com/sun/star/uno/Reference.h b/include/com/sun/star/uno/Reference.h
index e657fd8..af2dc29 100644
--- a/include/com/sun/star/uno/Reference.h
+++ b/include/com/sun/star/uno/Reference.h
@@ -93,6 +93,15 @@ public:
inline bool SAL_CALL is() const
{ return (NULL != _pInterface); }
+#if defined LIBO_INTERNAL_ONLY
+ /** Checks if reference is null.
+
+ @return true if reference acquires an interface, i.e. true if it is not null
+ */
+ inline explicit operator bool() const
+ { return is(); }
+#endif
+
/** Equality operator: compares two interfaces
Checks if both references are null or refer to the same object.
diff --git a/include/rtl/ref.hxx b/include/rtl/ref.hxx
index b70088b..5eeb857 100644
--- a/include/rtl/ref.hxx
+++ b/include/rtl/ref.hxx
@@ -195,6 +195,14 @@ public:
return (m_pBody != NULL);
}
+#if defined LIBO_INTERNAL_ONLY
+ /** Returns True if the handle does point to a valid body.
+ */
+ inline explicit operator bool() const
+ {
+ return is();
+ }
+#endif
/** Returns True if this points to pBody.
*/
diff --git a/include/tools/ref.hxx b/include/tools/ref.hxx
index c251a78..97a5b36 100644
--- a/include/tools/ref.hxx
+++ b/include/tools/ref.hxx
@@ -90,6 +90,8 @@ public:
bool Is() const { return pObj != nullptr; }
+ explicit operator bool() const { return Is(); }
+
T * get() const { return pObj; }
T * operator ->() const { assert(pObj != nullptr); return pObj; }
More information about the Libreoffice-commits
mailing list