c++exprtk

How to use exprtk to evaluate an equation as bool?


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?


Solution

  • 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 compatible with the standard floating point type.

    bool is not a floating-point type.