QBasicAtomic: add QT_BASIC_ATOMIC_HAS_CONSTRUCTORS macro

This macro is defined when the QBasicAtomic* types have constructors.
It will be used to simplify maintenance of QBasicAtomic subclasses,
as well as classes that aggregate Q(Basic)Atomics and wish to be
literal types if possible.

Change-Id: I7ab181c58a13ec2195449bbae5b3476b9017a8f2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2012-07-01 23:19:47 +02:00 committed by Qt by Nokia
parent 3ef95347fe
commit 21072c85b6

View File

@ -118,6 +118,10 @@ QT_END_HEADER
// New atomics
#if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS)
# define QT_BASIC_ATOMIC_HAS_CONSTRUCTORS
#endif
template <typename T>
class QBasicAtomicInteger
{
@ -179,7 +183,7 @@ public:
T fetchAndAddOrdered(T valueToAdd) Q_DECL_NOTHROW
{ return Ops::fetchAndAddOrdered(_q_value, valueToAdd); }
#if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS)
#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS
QBasicAtomicInteger() = default;
constexpr QBasicAtomicInteger(T value) Q_DECL_NOTHROW : _q_value(value) {}
QBasicAtomicInteger(const QBasicAtomicInteger &) = delete;
@ -243,7 +247,7 @@ public:
Type fetchAndAddOrdered(qptrdiff valueToAdd) Q_DECL_NOTHROW
{ return Ops::fetchAndAddOrdered(_q_value, valueToAdd); }
#if defined(Q_COMPILER_CONSTEXPR) && defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS)
#ifdef QT_BASIC_ATOMIC_HAS_CONSTRUCTORS
QBasicAtomicPointer() = default;
constexpr QBasicAtomicPointer(Type value) Q_DECL_NOTHROW : _q_value(value) {}
QBasicAtomicPointer(const QBasicAtomicPointer &) = delete;