Go to the documentation of this file.
9 #ifndef EAGINE_VALUE_TRACKER_HPP
10 #define EAGINE_VALUE_TRACKER_HPP
12 #include <type_traits>
18 template <
typename T,
typename Transform>
20 static_assert(std::is_arithmetic_v<T>);
28 : _prev{std::move(initial)} {}
32 : Transform(std::move(transf))
33 , _prev{std::move(initial)} {}
37 return _transform()(value);
41 auto get() const noexcept -> const T& {
55 auto _transform() noexcept -> Transform& {
65 template <
typename T, T D>
67 auto operator()(
const T& value) noexcept -> T {
74 template <
typename T, T D>
80 #endif // EAGINE_VALUE_TRACKER_HPP
Common code is placed in this namespace.
Definition: eagine.hpp:21
Transform class for value_change_tracker, dividing by the specified amount.
Definition: value_tracker.hpp:66
auto has_changed(const T &next) noexcept -> bool
If the transformed current and values are different, stores next.
Definition: value_tracker.hpp:46
value_change_tracker(T initial, Transform transf) noexcept
Constructor setting the initial value and the transform.
Definition: value_tracker.hpp:31
auto get() const noexcept -> const T &
Returns the currently stored value.
Definition: value_tracker.hpp:41
value_change_tracker(T initial) noexcept
Constructor setting the initial value.
Definition: value_tracker.hpp:27
Class tracking the changes in a potentially transformed value.
Definition: value_tracker.hpp:19
value_change_tracker() noexcept=default
Default constructor.
auto transform(const T &value) noexcept
Transforms the specified value.
Definition: value_tracker.hpp:36