Comparing std::functions for equality?

前端 未结 7 480
自闭症患者
自闭症患者 2020-12-03 04:47

How can I compare two C++11 std::functions with operator==, and return true if both of said functions refer to the same f

相关标签:
7条回答
  • 2020-12-03 05:13

    Be aware that equality of functions (deciding if two functions have always the same observable behavior) is an undecidable problem in lambda calculus (and that is why many programming languages forbid comparing functions).

    So even if the == test compiles, it would at most just test that the code is identical (has the same address), not that the compared functions have the same behaviour.

    0 讨论(0)
提交回复
热议问题