Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
MoveTracker.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2025, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include <utility>
23
24namespace util {
25
30 bool wasMoved_ = false;
31
32protected:
37 [[nodiscard]] bool
38 wasMoved() const noexcept
39 {
40 return wasMoved_;
41 }
42
43 MoveTracker() = default; // should only be used via inheritance
44
45public:
46 virtual ~MoveTracker() = default;
47
53 {
54 *this = std::move(other);
55 }
56
64 {
65 if (this != &other) {
66 other.wasMoved_ = true;
67 wasMoved_ = false;
68 }
69
70 return *this;
71 }
72
73 MoveTracker(MoveTracker const&) = default;
75 operator=(MoveTracker const&) = default;
76};
77
78} // namespace util
A base-class that can be used to check whether the current instance was moved from.
Definition MoveTracker.hpp:29
MoveTracker(MoveTracker &&other)
Move constructor sets the moved-from state on other and resets the state on this
Definition MoveTracker.hpp:52
MoveTracker & operator=(MoveTracker &&other)
Move operator sets the moved-from state on other and resets the state on this
Definition MoveTracker.hpp:63
bool wasMoved() const noexcept
The function to be used by clients in order to check whether the instance was moved from.
Definition MoveTracker.hpp:38
This namespace contains various utilities.
Definition AccountUtils.hpp:30