38 std::time_t time_ = 0;
56 value_ = other.value_;
65 value_ = std::move(other.value_);
66 time_ = std::move(other.time_);
73 const T&
value()
const {
return value_; }
79 std::time_t
time()
const {
return time_; }
91 void Set(
const T& val) {
93 time_ = std::time(
nullptr);
103 time_ = std::time(
nullptr);
113 value_ = other.value_;
124 value_ = std::move(other.value_);
125 time_ = std::move(other.time_);
133 explicit operator const T&()
const {
return value_; }
Template class for keeping track of when a variable is modified.
Definition temporal.hh:35
const T * operator->() const
Arrow operator forwarding to the stored value.
Definition temporal.hh:139
temporal< T > & operator=(const temporal< T > &other)
Copy-assigns from another temporal wrapper.
Definition temporal.hh:112
temporal(const temporal< T > &other)
Copy-constructs from another temporal wrapper.
Definition temporal.hh:55
void set_time(std::time_t time)
Sets the modification timestamp without changing the value.
Definition temporal.hh:85
temporal(temporal< T > &&other) noexcept
Move-constructs from another temporal wrapper.
Definition temporal.hh:64
temporal()=default
Default-constructs an empty temporal wrapper.
temporal< T > & operator=(const T &value)
Assigns a plain value, updating the timestamp to now.
Definition temporal.hh:101
const T & value() const
Returns a const reference to the stored value.
Definition temporal.hh:73
temporal(const T &value, std::time_t time)
Constructs a temporal wrapper with an explicit timestamp.
Definition temporal.hh:49
void Set(const T &val)
Replaces the stored value and updates the timestamp to now.
Definition temporal.hh:91
const T & operator*() const
Dereference operator forwarding to the stored value.
Definition temporal.hh:145
temporal< T > & operator=(temporal< T > &&other) noexcept
Move-assigns from another temporal wrapper.
Definition temporal.hh:123
std::time_t time() const
Returns the modification timestamp.
Definition temporal.hh:79