summaryrefslogtreecommitdiff
path: root/number.h
diff options
context:
space:
mode:
authorOlivier Gayot <og@satcom1.com>2017-11-19 16:01:31 +0100
committerOlivier Gayot <og@satcom1.com>2017-11-19 16:21:05 +0100
commitc382010ae2e764bf7bbdf467c3d9a115a2113e50 (patch)
tree1faa7d743b50bfc8f98595ddb0a44035144971d8 /number.h
parentd7d33b9779232972a1281bfddc1cf2626ec36050 (diff)
Added bool operator and ! operator
We can now check if a number evaluates to false or true by doing a conversion to bool or use the ! operator. Signed-off-by: Olivier Gayot <og@satcom1.com>
Diffstat (limited to 'number.h')
-rw-r--r--number.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/number.h b/number.h
index f68299d..c920ddc 100644
--- a/number.h
+++ b/number.h
@@ -34,6 +34,12 @@ public:
std::uint32_t to_uint32() const;
/**
+ * \brief Return true if this number is not equal to 0. Otherwise, return
+ * false.
+ */
+ explicit operator bool() const;
+
+ /**
* \brief Return the result of the addition of a number and this number.
*
* \param n The number to add to this number.
@@ -105,6 +111,11 @@ public:
bool operator!=(const number &n) const;
/**
+ * \brief Tells whether this number evaluates to false.
+ */
+ bool operator!() const;
+
+ /**
* \brief Add a number to this number.
*
* \param n Number to add to this number.