0

I'm trying to run this code:

exprtk::parser<bool> parser;
exprtk::expression<bool> expression;
parser.compile("5 > 6", expression);
std::cout << expression.value() << "\n";

But I get this error:

'exprtk::expression<T>::operator T(void) const': member function already defined or declared

On VS 2019. This doesn't happen when I use other data types. Is this a bug or am I doing something wrong?

SJS
  • 139
  • 1
  • 3
  • 13

1 Answers1

2

From the documentation:

exprtk::expression<NumericType>

Note: NumericType can be any floating point type. This includes but is not limited to: float, double, long double, MPFR or any custom type conforming to an interface comptaible (sic) with the standard floating point type.

bool is not a floating-point type.

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
  • I see, so the only way would be to see if the result is non-zero? – SJS Jun 23 '21 at 17:01
  • @GameBoss9000, `5 > 6` return `0`, and `6 > 5` returns `1`. I _think_ the library converts true to 1, and false to 0. – ChrisMM Jun 23 '21 at 17:03