diff options
author | Olivier Gayot <og@satcom1.com> | 2017-11-19 16:01:31 +0100 |
---|---|---|
committer | Olivier Gayot <og@satcom1.com> | 2017-11-19 16:21:05 +0100 |
commit | c382010ae2e764bf7bbdf467c3d9a115a2113e50 (patch) | |
tree | 1faa7d743b50bfc8f98595ddb0a44035144971d8 /number.cpp | |
parent | d7d33b9779232972a1281bfddc1cf2626ec36050 (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.cpp')
-rw-r--r-- | number.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -70,6 +70,11 @@ number::to_uint32() const return (*this == 0) ? 0 : _operands.front(); } +number::operator bool() const +{ + return *this != 0; +} + /* }}} */ /* Operations {{{ */ @@ -226,6 +231,12 @@ number::operator!=(const number &n) const return _operands != n._operands; } +bool +number::operator!() const +{ + return !static_cast<bool>(*this); +} + /* }}} */ /* Assignment operators {{{ */ |