I am trying to compare two Blitz++ Arrays, but I am getting a compiler error saying that the expression cannot be converted into a boolean.
According to the documentation this operation should be supported.
What am I doing wrong?
Code:
#include <blitz/array.h>
int main() {
blitz::Array<double, 2> a(1, 1);
blitz::Array<double, 2> b(1, 1);
bool c = (a == b);
return 0;
}
Error:
error: cannot convert ‘blitz::BzBinaryExprResult<blitz::Equal, blitz::Array<double, 2>, blitz::Array<double, 2> >::T_result’ {aka ‘blitz::_bz_ArrayExpr<blitz::_bz_ArrayExprBinaryOp<blitz::_bz_ArrayExpr<blitz::FastArrayIterator<double, 2> >, blitz::_bz_ArrayExpr<blitz::FastArrayIterator<double, 2> >, blitz::Equal<double, double> > >’} to ‘bool’ in initialization
blitz::Array<bool, 2> result(a == b);
or
bool c = blitz::all(blitz::Array<bool, 2>(a == b));
the conversion from expression to array is explicit.