Problem: I have a set of classes for which I have already implemented boost serialization methods. Now, I want to add an operator==
to one class that contains many of the other classes as its members. This comparison should be straightforward: A deep, member wise comparison.
Idea: Since the existing serialization methods already tell the compiler everything it needs to know, I wonder if this can be used to generate efficient comparison operators.
Approach 1: The simplest thing would be to compare strings containing serializations of the objects to be compared. The runtime of this approach is probably much slower than handcrafted operator==
implementations.
Approach 2: Implement a specialized boost serialization archive for comparisons. However, implementing this is much more complicated and time consuming than implementing either handcrafted operators or approach 1.