Overloading logical operators considered bad practice?

前端 未结 7 666
星月不相逢
星月不相逢 2021-01-11 13:40

Is it a bad idea to overload &&, || or comma operator and Why?

7条回答
  •  囚心锁ツ
    2021-01-11 14:21

    As the others have said, missing lazy evaluation is the main reason to avoid overloading logical operators.

    However, there is one very good reason to overload them: Expression templates. The Boost.Lambda library does this, and it's very useful!

提交回复
热议问题