bool.h 740 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <library/cpp/deprecated/atomic/atomic.h>
  3. namespace NAtomic {
  4. class TBool {
  5. public:
  6. TBool() noexcept = default;
  7. TBool(bool val) noexcept
  8. : Val_(val)
  9. {
  10. }
  11. TBool(const TBool& src) noexcept {
  12. AtomicSet(Val_, AtomicGet(src.Val_));
  13. }
  14. operator bool() const noexcept {
  15. return AtomicGet(Val_);
  16. }
  17. const TBool& operator=(bool val) noexcept {
  18. AtomicSet(Val_, val);
  19. return *this;
  20. }
  21. const TBool& operator=(const TBool& src) noexcept {
  22. AtomicSet(Val_, AtomicGet(src.Val_));
  23. return *this;
  24. }
  25. private:
  26. TAtomic Val_ = 0;
  27. };
  28. }