[gtksourceviewmm] C++11: Markup: Deprecated operator const void*(), adding explicit operator bool().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceviewmm] C++11: Markup: Deprecated operator const void*(), adding explicit operator bool().
- Date: Sun, 10 Apr 2016 14:29:49 +0000 (UTC)
commit 60565786a5d0f5089489134eb8c0c0dfe796d680
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Apr 10 16:22:47 2016 +0200
C++11: Markup: Deprecated operator const void*(), adding explicit operator bool().
gtksourceview/gtksourceviewmm/markup.cc | 7 +++++++
gtksourceview/gtksourceviewmm/markup.h | 19 +++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourceviewmm/markup.cc b/gtksourceview/gtksourceviewmm/markup.cc
index d853a4f..f2450d2 100644
--- a/gtksourceview/gtksourceviewmm/markup.cc
+++ b/gtksourceview/gtksourceviewmm/markup.cc
@@ -52,10 +52,17 @@ Markup& Markup::operator=(const Markup& other)
return *this;
}
+#ifndef GTKMM_DISABLE_DEPRECATED
Markup::operator const void*() const
{
return !(markup_.empty()) ? GINT_TO_POINTER(1) : 0;
}
+#endif // GTKMM_DISABLE_DEPRECATED
+
+Markup::operator bool() const
+{
+ return !(markup_.empty());
+}
bool Markup::equal(const Markup& rhs) const
{
diff --git a/gtksourceview/gtksourceviewmm/markup.h b/gtksourceview/gtksourceviewmm/markup.h
index d4b82ba..56f98cf 100644
--- a/gtksourceview/gtksourceviewmm/markup.h
+++ b/gtksourceview/gtksourceviewmm/markup.h
@@ -87,8 +87,11 @@ public:
*/
Markup& operator=(const Markup& other);
+#ifndef GTKMM_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.
*/
typedef const void* BoolExpr;
@@ -102,8 +105,24 @@ public:
* @return @c true if Markup is not empty, otherwise @c false.
*
* @newin{2,10}
+ *
+ * @deprecated Use the explicit operator bool() instead.
*/
operator BoolExpr() const;
+#endif // GTKMM_DISABLE_DEPRECATED
+
+ /** Checks if Markup is not empty.
+ * For instance,
+ * @code
+ * if(markup)
+ * do_something()
+ * @endcode
+ *
+ * @return @c true if Markup is not empty, otherwise @c false.
+ *
+ * @newin{3,20}
+ */
+ explicit operator bool() const;
/** Checks if @a other Markup is the same as this one.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]