Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
MoveTracker.hpp
1#pragma once
2
3#include <utility>
4
5namespace util {
6
10class MoveTracker {
11 bool wasMoved_ = false;
12
13protected:
19 [[nodiscard]] bool
20 wasMoved() const noexcept
21 {
22 return wasMoved_;
23 }
24
25 MoveTracker() = default; // should only be used via inheritance
26
27public:
28 virtual ~MoveTracker() = default;
29
34 MoveTracker(MoveTracker&& other)
35 {
36 *this = std::move(other);
37 }
38
45 operator=(MoveTracker&& other)
46 {
47 if (this != &other) {
48 other.wasMoved_ = true;
49 wasMoved_ = false;
50 }
51
52 return *this;
53 }
54
55 MoveTracker(MoveTracker const&) = default;
57 operator=(MoveTracker const&) = default;
58};
59
60} // namespace util
A base-class that can be used to check whether the current instance was moved from.
Definition MoveTracker.hpp:10
MoveTracker(MoveTracker &&other)
Move constructor sets the moved-from state on other and resets the state on this.
Definition MoveTracker.hpp:34
MoveTracker & operator=(MoveTracker &&other)
Move operator sets the moved-from state on other and resets the state on this.
Definition MoveTracker.hpp:45
bool wasMoved() const noexcept
The function to be used by clients in order to check whether the instance was moved from.
Definition MoveTracker.hpp:20
This namespace contains various utilities.
Definition AccountUtils.hpp:11