您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

43 行
928 B

  1. #pragma once
  2. #include <ecs/config.h>
  3. beg_namespace_ecs_core_utils
  4. {
  5. template<typename T>
  6. struct movable_atomic final
  7. : std::atomic<T>
  8. {
  9. private:
  10. using base_type = std::atomic<T>;
  11. public:
  12. using base_type::base_type;
  13. movable_atomic() = default;
  14. movable_atomic(const movable_atomic&) = delete;
  15. movable_atomic(movable_atomic&& other) noexcept
  16. : base_type(other.load())
  17. { }
  18. movable_atomic& operator=(const movable_atomic&) = delete;
  19. movable_atomic& operator=(movable_atomic&& other) noexcept
  20. {
  21. this->store(other.load());
  22. return *this;
  23. }
  24. template<T value>
  25. movable_atomic& operator=(std::integral_constant<T, value> x) noexcept
  26. {
  27. this->store(decltype(x)::value);
  28. return *this;
  29. }
  30. };
  31. }
  32. end_namespace_ecs_core_utils