[glibmm] VariantBase: Add explicit operator bool().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] VariantBase: Add explicit operator bool().
- Date: Sun, 10 Apr 2016 11:56:13 +0000 (UTC)
commit 35af42466f6b36fe222b2e7a80589ff12004b1f8
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Apr 10 13:51:53 2016 +0200
VariantBase: Add explicit operator bool().
Deprecating the operator const void*, which is no longer necessary
with C++11.
There doesn't seem to be any ambiguity, but let's see.
glib/src/variant.ccg | 7 +++++++
glib/src/variant.hg | 12 ++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index bde8b4b..a95e390 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -249,10 +249,17 @@ VariantContainerBase::get_iter(const VariantType& container_variant_type) const
/****************** Specializations ***********************************/
+#ifndef GLIBMM_DISABLE_DEPRECATED
VariantBase::operator const void*() const
{
return gobj() ? GINT_TO_POINTER(1) : nullptr;
}
+#endif // GLIBMM_DISABLE_DEPRECATED
+
+VariantBase::operator bool() const
+{
+ return gobj() ? GINT_TO_POINTER(1) : nullptr;
+}
void
VariantBase::init(const GVariant* cobject, bool take_a_reference)
diff --git a/glib/src/variant.hg b/glib/src/variant.hg
index c90fa55..7927a4d 100644
--- a/glib/src/variant.hg
+++ b/glib/src/variant.hg
@@ -95,8 +95,11 @@ class VariantBase
g_variant_get, g_variant_get_va)
public:
+#ifndef GLIBMM_DISABLE_DEPRECATED
/** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
+ *
+ * @deprecated Use the explicit operator bool() instead.
*/
using BoolExpr = const void*;
@@ -108,9 +111,18 @@ public:
* do_something();
* @endcode
*
+ * @deprecated Use the explicit operator bool() instead.
+ *
* @newin{2,36}
*/
operator BoolExpr() const;
+#endif // GLIBMM_DISABLE_DEPRECATED
+
+ /** Test whether the Variant has an underlying instance.
+ *
+ * @newin{2,50}
+ */
+ explicit operator bool() const;
/** Replace the underlying GVariant.
* This is for use by methods that take a VariantBase& as an output
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]