From c382010ae2e764bf7bbdf467c3d9a115a2113e50 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sun, 19 Nov 2017 16:01:31 +0100 Subject: 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 --- number.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'number.h') diff --git a/number.h b/number.h index f68299d..c920ddc 100644 --- a/number.h +++ b/number.h @@ -33,6 +33,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. * @@ -104,6 +110,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. * -- cgit v1.2.3