-
Alessandro Di Federico authored
Sometimes, dealing with move-semantics in C++ can be challenging. To mitigate this problem, this commit introduces `ClassSentinel`, a simple class that can be added as a member of a class and that will allow the user to easily monitor if an instance of a class is used after being moved in an unwanted way. To do so, simply call the `ClassSentinel::check` method on the class member. `ClassSentinel` performs similar (but less reliable) checks on usage of destroyed objects. `ClassSentinel` can also (optionally, though the `SENTINEL_STACKTRACES` macro) collect stack traces of the points where the object was moved or destroyed. This commit also includes some basic testing for the class.
Alessandro Di Federico authoredSometimes, dealing with move-semantics in C++ can be challenging. To mitigate this problem, this commit introduces `ClassSentinel`, a simple class that can be added as a member of a class and that will allow the user to easily monitor if an instance of a class is used after being moved in an unwanted way. To do so, simply call the `ClassSentinel::check` method on the class member. `ClassSentinel` performs similar (but less reliable) checks on usage of destroyed objects. `ClassSentinel` can also (optionally, though the `SENTINEL_STACKTRACES` macro) collect stack traces of the points where the object was moved or destroyed. This commit also includes some basic testing for the class.
Loading