Sometimes users implement functions with equivalent functionality as their implicitly defined versions. For example, a copy constructor that simply calls the copy constructor of all its members.
struct A
{
int B;
A(const A& a) : B(a.B) { }
}
This is undesirable because it causes additional maintenance, for example, if class members are renamed / reordered, etc., and reduces readability. In addition, adding these functions also means that functions such as std::is_trivially_copy_constructable
state that a type cannot be trivially copied (but in practice it really can be).
I have a code base where this seems like a common occurrence that I would like to fix by deleting these implementations. However, I'm worried about removing functionality that seems to be identical to the implicit implementation, in case it cannot be actually equivalent. Is there a way to determine if a function is equivalent to its implicit version? (The use of any options of a set of tools / language / etc. is acceptable).
source
share