I made bit flags using a scoped enum, and I overload operator |
to combine values:
enum class PARAM_T : int {
NONE = 0x0,
INPUT = 0x01,
OUTPUT = 0x02,
OUTPUT_VECTOR = 0x04
};
inline PARAM_T operator | (PARAM_T lhs, PARAM_T rhs)
{
using T = std::underlying_type_t<PARAM_T>;
return (PARAM_T)(static_cast<T>(lhs) | static_cast<T>(rhs));
}
Elsewhere in my project, I do some drag/drop operations using Qt widgets, where I use operator |
to combine some named constants:
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
The operator |
here is unrelated to my bit flags, yet for some reason my overload breaks this line of code, giving the following error:
error C2664: 'Qt::DropAction QDrag::exec(Qt::DropActions,Qt::DropAction)' : cannot convert argument 1 from 'int' to 'Qt::DropActions'
Why is the compiler matching Qt constants to my overload? They are entirely different and incompatible types.