On Tuesday, 28 November 2017 02:31:12 UTC+2, Christopher Pisz wrote:
<snipping to point>
> So, please make me a believer!
I use rule of zero as quite strong rule and can help to administer
it, but beware, my worldview is not a cult. It does not work on
belief. C++ is full of traps. Period. It is workable with awareness
understanding and on pile of tricks. If some "silver bullet" seems
to work always then it is actually superstition. You will be trapped
and then we all cheer "Gotcha!!". ;)
> Tell me how I can accomplish the above described debugging
> session given a crash dump, when there is no line available to break
> on, after being a good boy and following the "Rule of Zero".
>
> Namely:
>
> 1) Break any time any instance of a given class is being constructed
> without any lines of constructor code to break on.
>
> 2) Break any time any instance of a given class is being assigned to
> without any lines of assignment operator to break on.
Yes, our debuggers typically have no feature to break and to step
in implicitly generated code. When we only want to break or to trace
from the 5 then it is not too tricky to simplify it by typical separation
of concerns.
For example we can add a special member (or base) to our class with
all 5 members explicitly implemented. Implicitly-generated 5 are
required to call the 5 of such base or member and so we can break
in (or trace from) such stock class (or more likely template) instead
of implementing the 5 in every containing class.
That is already useful but we can further extend it with flexibility
features like:
1) to turn the fact of presence of such member on and off compile-time
2) to inject some other "indicating operations" besides trace into it
3) to select if it does its operation and from what members on and
off run-time
... and so on ...
As result instrumentation code can be left in forever and so can
be useful in unit-tests as well. Hopefully you see how to implement
such thing is lot more interesting and beneficial than to tediously
and error-pronely implement the 5 for each and every class.