|
mimic++ v9.2.1
|
A watcher type, which reports it's destructor calls. More...
#include <ObjectWatcher.hpp>
Public Member Functions | |
| ~LifetimeWatcher () noexcept(false) | |
| Destructor, which reports the call. | |
| LifetimeWatcher ()=default | |
| Default constructor. | |
| template<typename Base> | |
| LifetimeWatcher (const for_base_tag< Base >) | |
| LifetimeWatcher (const LifetimeWatcher &other) | |
| Copy-constructor. | |
| LifetimeWatcher & | operator= (const LifetimeWatcher &other) |
| Copy-assignment-operator. | |
| LifetimeWatcher (LifetimeWatcher &&)=default | |
| Defaulted move-constructor. | |
| LifetimeWatcher & | operator= (LifetimeWatcher &&)=default |
| Defaulted move-assignment-operator. | |
| auto | expect_destruct () |
| Begins a destruction-expectation construction. | |
A watcher type, which reports it's destructor calls.
This watcher is designed to track, whether the destructor has been called. During its destructor call, it reports the destruction to the framework, which can be tracked by a previously created destruction-expectation.
This watcher can be freely moved around.
This watcher is copyable, but with very special behaviour.
As this watcher is generally designed to be part of a bigger object, it would be very limiting not supporting copy-operations at all. The question is, how should a copy look like?
In general a copy should be a logical duplicate of its source and the general expectation is: if B is a copy of A, then A == B should yield true.
B is not a copy of A, then A == B has to yield false!This won't be the case for LifetimeWatchers, as active destruction-expectations won't be copied over to the target. In general, if a LifetimeWatcher is used, we want to be very precise with our object-lifetime, thus an implicit expectation copy would be against the purpose of this helper. Due to this, each LifetimeWatcher will be created as a fresh instance, when copy-construction is used. The same logic also applies to copy-assignment.