Tag Archives: error c2678 <

[Solved] Error: error c2678: binary ‘<', no left operand operator (or no acceptable conversion) that accepts type 'const a' was found

Scenario: define a structure a, and then STD:: Map < A, B> m;

Error: error c2678: binary ‘<‘, no left operand operator (or no acceptable conversion) that accepts type ‘const a’ was found

Reason: overloaded “<“, const is not added after the parameter list

Solution: add const after the parameter list

bool operator < (const A& v) const
{
    ...
}

Note: if “<” is not overloaded, many errors will be reported. C2784 can not deduce the parameter template error