fork download
  1. #include <iostream>
  2. #include <atomic>
  3.  
  4. #define Q_DECL_NOTHROW noexcept
  5. #define QT_BASIC_ATOMIC_HAS_CONSTRUCTORS
  6.  
  7. template <typename T> struct QAtomicOps
  8. {
  9. typedef std::atomic<T> Type;
  10. };
  11.  
  12. template <typename T>
  13. class QBasicAtomicInteger
  14. {
  15. public:
  16. typedef QAtomicOps<T> Ops;
  17. typename Ops::Type _q_value;
  18.  
  19. #ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS
  20. QBasicAtomicInteger() = default;
  21. constexpr QBasicAtomicInteger(T value) Q_DECL_NOTHROW : _q_value(value) {}
  22. QBasicAtomicInteger(const QBasicAtomicInteger &) = delete;
  23. QBasicAtomicInteger &operator=(const QBasicAtomicInteger &) = delete;
  24. QBasicAtomicInteger &operator=(const QBasicAtomicInteger &) volatile = delete;
  25. #endif
  26. };
  27. typedef QBasicAtomicInteger<int> QBasicAtomicInt;
  28.  
  29. #ifndef Q_BASIC_ATOMIC_INITIALIZER
  30. # define Q_BASIC_ATOMIC_INITIALIZER(a) { (a) }
  31. #endif
  32.  
  33. struct QMetaTypeIdQObject
  34. {
  35. enum {
  36. Defined = 1
  37. };
  38.  
  39. static int qt_metatype_id()
  40. {
  41. static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
  42. return metatype_id._q_value;
  43. }
  44. };
  45.  
  46. int main()
  47. {
  48. std::cout << QMetaTypeIdQObject::qt_metatype_id() << std::endl;
  49.  
  50. return 0;
  51. }
  52.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty