6#ifndef MIMICPP_OBJECT_WATCHER_HPP
7#define MIMICPP_OBJECT_WATCHER_HPP
66 if (
const auto destruction = std::exchange(
152 if (std::exchange(m_HasDestructExpectation,
true))
154 throw std::logic_error{
155 "LifetimeWatcher: A destruct expectation can not be created more than once for a single instance."
159 return m_DestructionMock->expect_call()
164 bool m_HasDestructExpectation{};
165 std::unique_ptr<Mock<void()>> m_DestructionMock{
166 std::make_unique<Mock<void()>>()
238 m_RelocationMock =
Mock<void()>{};
251 *
this = std::move(other);
261 other.m_RelocationMock();
262 m_RelocationMock = std::move(other).m_RelocationMock;
277 return m_RelocationMock.expect_call();
281 Mock<void()> m_RelocationMock{};
284 template <
typename T>
286 && std::is_copy_constructible_v<T>
287 && std::is_copy_assignable_v<T>
288 && std::is_move_constructible_v<T>
289 && std::is_move_assignable_v<T>
290 && std::is_destructible_v<T>;
294 template <
typename Base,
typename... Watchers>
295 class CombinedWatchers
299 ~CombinedWatchers()
noexcept(std::is_nothrow_destructible_v<Base>) =
default;
301 CombinedWatchers() =
default;
303 CombinedWatchers(
const CombinedWatchers&) =
default;
304 CombinedWatchers& operator =(
const CombinedWatchers&) =
default;
306 CombinedWatchers(CombinedWatchers&& other)
noexcept(std::is_nothrow_move_constructible_v<Base>) =
default;
307 CombinedWatchers& operator =(CombinedWatchers&& other)
noexcept(std::is_nothrow_move_assignable_v<Base>) =
default;
310 template <
typename Base,
typename... Watchers>
312 :
public CombinedWatchers<Base, Watchers...>,
316 ~BasicWatched() =
default;
320 BasicWatched(
const BasicWatched&) =
default;
321 BasicWatched& operator =(
const BasicWatched&) =
default;
322 BasicWatched(BasicWatched&&) =
default;
323 BasicWatched& operator =(BasicWatched&&) =
default;
326 template <satisfies<std::has_virtual_destructor> Base,
typename... Watchers>
327 class BasicWatched<Base, Watchers...>
328 :
public CombinedWatchers<Base, Watchers...>,
332 ~BasicWatched()
override =
default;
336 BasicWatched(
const BasicWatched&) =
default;
337 BasicWatched& operator =(
const BasicWatched&) =
default;
338 BasicWatched(BasicWatched&&) =
default;
339 BasicWatched& operator =(BasicWatched&&) =
default;
397 requires std::same_as<Base, std::remove_cvref_t<Base>>
399 :
public detail::BasicWatched<Base, Watchers...>
401 using SuperT = detail::BasicWatched<Base, Watchers...>;
406 using SuperT::SuperT;
A watcher type, which reports it's destructor calls.
Definition ObjectWatcher.hpp:57
LifetimeWatcher()=default
Defaulted default constructor.
~LifetimeWatcher() noexcept(false)
Destructor, which reports the call.
Definition ObjectWatcher.hpp:64
LifetimeWatcher(const LifetimeWatcher &other)
Copy-constructor.
Definition ObjectWatcher.hpp:91
LifetimeWatcher & operator=(const LifetimeWatcher &other)
Copy-assignment-operator.
Definition ObjectWatcher.hpp:111
LifetimeWatcher(LifetimeWatcher &&)=default
Defaulted move-constructor.
auto expect_destruct()
Begins a destruction-expectation construction.
Definition ObjectWatcher.hpp:150
A Mock type, which fully supports overload sets.
Definition Mock.hpp:600
A watcher type, which reports it's move-constructor and -assignment calls.
Definition ObjectWatcher.hpp:201
auto expect_relocate()
Begins a relocation-expectation construction.
Definition ObjectWatcher.hpp:275
RelocationWatcher(RelocationWatcher &&other) noexcept(false)
Move-constructor, which reports a relocation.
Definition ObjectWatcher.hpp:249
~RelocationWatcher()=default
Defaulted destructor.
RelocationWatcher(const RelocationWatcher &other)
Copy-constructor.
Definition ObjectWatcher.hpp:222
RelocationWatcher()=default
Defaulted default constructor.
RelocationWatcher & operator=(const RelocationWatcher &other)
Copy-assignment-operator.
Definition ObjectWatcher.hpp:234
CRTP-type, inheriting first from all Watchers and then Base, thus effectively couple them all togethe...
Definition ObjectWatcher.hpp:400
Watched(const Watched &)=default
Watched & operator=(const Watched &)=default
Watched(Watched &&)=default
Definition ObjectWatcher.hpp:285
consteval auto once() noexcept
Specifies a times policy with both limits set to 1.
Definition ControlPolicy.hpp:356
Definition BoostTest.hpp:20