From 1db2c5ca0ff0c05783726899059c7b8e09fe07c6 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 21 Aug 2017 01:09:52 +0200 Subject: [PATCH] Allow ! and bool operators on polynomials. This allows us to manipulate polynomials of polynomials. Not sure why yet, but it could be useful to implement 2-variable polynomials. --- src/lol/math/polynomial.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lol/math/polynomial.h b/src/lol/math/polynomial.h index a140314b..e55f4126 100644 --- a/src/lol/math/polynomial.h +++ b/src/lol/math/polynomial.h @@ -274,6 +274,17 @@ struct LOL_ATTR_NODISCARD polynomial return (*this)[degree()]; } + /* Boolean operations */ + bool operator !() const + { + return degree() < 0; + } + + operator bool() const + { + return !!*this; + } + /* Unary plus */ polynomial operator +() const {