Lazy, overloaded C++ && operator?

后端 未结 4 601
情歌与酒
情歌与酒 2021-01-18 01:07

I\'m trying to implement my own boolean class, but cannot replicate native semantics for &&. The following contrived code demonstrates the issue:



          


        
4条回答
  •  生来不讨喜
    2021-01-18 01:34

    You can make almost anything evaluate lazily with the expression template idiom, including but not limited to the operators whose built-in versions short-circuit. But that's more work than you need for this one case, since then your MyBool class would require a lot more code.

提交回复
热议问题