An exploration of a bug encountered with polymorphic equality in C++ and methods to resolve it. The post details the problem with defaulted equality leading to infinite recursion and provides several solutions, including changing the comparator in the base class, wrapping derived class members, and using reflection for member-wise comparison.

6m read timeFrom brevzin.github.io
Post cover image
Table of contents
The SetupThe IssueThe SolutionThe Conclusion

Sort: