|
- #pragma once
-
- #include <ecs/config.h>
-
- beg_namespace_ecs_core_utils
- {
-
- template<typename T>
- struct movable_atomic final
- : std::atomic<T>
- {
- private:
- using base_type = std::atomic<T>;
-
- public:
- using base_type::base_type;
-
- movable_atomic() = default;
-
- movable_atomic(const movable_atomic&) = delete;
-
- movable_atomic(movable_atomic&& other) noexcept
- : base_type(other.load())
- { }
-
- movable_atomic& operator=(const movable_atomic&) = delete;
-
- movable_atomic& operator=(movable_atomic&& other) noexcept
- {
- this->store(other.load());
- return *this;
- }
-
- template<T value>
- movable_atomic& operator=(std::integral_constant<T, value> x) noexcept
- {
- this->store(decltype(x)::value);
- return *this;
- }
- };
-
- }
- end_namespace_ecs_core_utils
|