CppCoreGuidelines icon indicating copy to clipboard operation
CppCoreGuidelines copied to clipboard

Guideline against unconventional overloads

Open eisenwave opened this issue 2 years ago • 2 comments

Should there be a guideline recommending against overloading operators that people almost never anticipate to be overloaded? This would include things like:

  • overloading the comma operator
  • overloading logical AND and logical OR

There is fairly strong consensus in the community that doing so is questionable at best, and afaik standard libraries aren't all comma-safe either.

eisenwave avatar Aug 11 '23 18:08 eisenwave

I'd add the unary & to that list.

jwakely avatar Aug 11 '23 18:08 jwakely

For every reasonable expectation of operator overloading, there is boost.spirit

cubbimew avatar Aug 11 '23 18:08 cubbimew