Linked Questions

Popular Questions

This is an overloaded || operator defined in my class:

bool operator|| (const MyClass& v) const {
    return ......;  //some calculation

The compiler reports an warning:

warning: user-defined 'bool MyClass::operator||(const MyClass&) const' always evaluates both arguments [-Weffc++]

I understand the warning because built-in || is short-circuit which might be different from what the user-defined operator intends to behave. But the thing is, I am required to have -Weffc++ turned on and any warning is not allowed. So what code of || overloading can resolve this warning (i.e., suppress this warning)? Thank you.

I'm using g++ 5.4.0 on Ubuntu 16.04.

Related Questions