Add a couple of noexcept
Change-Id: I993da2094482092540388ee72be3262bac94fad7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
fbce2e58e6
commit
c129362b4d
@ -64,30 +64,30 @@ struct Q_CORE_EXPORT QArrayData
|
||||
uint flags;
|
||||
uint alloc;
|
||||
|
||||
inline size_t allocatedCapacity()
|
||||
inline size_t allocatedCapacity() noexcept
|
||||
{
|
||||
return alloc;
|
||||
}
|
||||
|
||||
inline size_t constAllocatedCapacity() const
|
||||
inline size_t constAllocatedCapacity() const noexcept
|
||||
{
|
||||
return alloc;
|
||||
}
|
||||
|
||||
/// Returns true if sharing took place
|
||||
bool ref()
|
||||
bool ref() noexcept
|
||||
{
|
||||
ref_.ref();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Returns false if deallocation is necessary
|
||||
bool deref()
|
||||
bool deref() noexcept
|
||||
{
|
||||
return ref_.deref();
|
||||
}
|
||||
|
||||
bool isShared() const
|
||||
bool isShared() const noexcept
|
||||
{
|
||||
return ref_.loadRelaxed() != 1;
|
||||
}
|
||||
@ -95,19 +95,19 @@ struct Q_CORE_EXPORT QArrayData
|
||||
// Returns true if a detach is necessary before modifying the data
|
||||
// This method is intentionally not const: if you want to know whether
|
||||
// detaching is necessary, you should be in a non-const function already
|
||||
bool needsDetach()
|
||||
bool needsDetach() const noexcept
|
||||
{
|
||||
return ref_.loadRelaxed() > 1;
|
||||
}
|
||||
|
||||
size_t detachCapacity(size_t newSize) const
|
||||
size_t detachCapacity(size_t newSize) const noexcept
|
||||
{
|
||||
if (flags & CapacityReserved && newSize < constAllocatedCapacity())
|
||||
return constAllocatedCapacity();
|
||||
return newSize;
|
||||
}
|
||||
|
||||
ArrayOptions detachFlags() const
|
||||
ArrayOptions detachFlags() const noexcept
|
||||
{
|
||||
ArrayOptions result = DefaultAllocationFlags;
|
||||
if (flags & CapacityReserved)
|
||||
@ -160,7 +160,7 @@ struct QTypedArrayData
|
||||
return qMakePair(static_cast<QTypedArrayData *>(pair.first), static_cast<T *>(pair.second));
|
||||
}
|
||||
|
||||
static void deallocate(QArrayData *data)
|
||||
static void deallocate(QArrayData *data) noexcept
|
||||
{
|
||||
static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData));
|
||||
QArrayData::deallocate(data, sizeof(T), alignof(AlignmentDummy));
|
||||
|
@ -75,12 +75,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
explicit QArrayDataPointer(QPair<QTypedArrayData<T> *, T *> adata, size_t n = 0)
|
||||
explicit QArrayDataPointer(QPair<QTypedArrayData<T> *, T *> adata, size_t n = 0) noexcept
|
||||
: d(adata.first), ptr(adata.second), size(int(n))
|
||||
{
|
||||
}
|
||||
|
||||
static QArrayDataPointer fromRawData(const T *rawData, size_t length)
|
||||
static QArrayDataPointer fromRawData(const T *rawData, size_t length) noexcept
|
||||
{
|
||||
Q_ASSERT(rawData || !length);
|
||||
return { nullptr, const_cast<T *>(rawData), length };
|
||||
@ -157,7 +157,7 @@ public:
|
||||
qSwap(size, other.size);
|
||||
}
|
||||
|
||||
void clear() Q_DECL_NOEXCEPT_EXPR(std::is_nothrow_destructible<T>::value)
|
||||
void clear() noexcept(std::is_nothrow_destructible<T>::value)
|
||||
{
|
||||
QArrayDataPointer tmp;
|
||||
swap(tmp);
|
||||
@ -187,11 +187,11 @@ public:
|
||||
bool needsDetach() const noexcept { return !d || d->needsDetach(); }
|
||||
size_t detachCapacity(size_t newSize) const noexcept { return d ? d->detachCapacity(newSize) : newSize; }
|
||||
const typename Data::ArrayOptions flags() const noexcept { return d ? typename Data::ArrayOption(d->flags) : Data::DefaultAllocationFlags; }
|
||||
void setFlag(typename Data::ArrayOptions f) { Q_ASSERT(d); d->flags |= f; }
|
||||
void clearFlag(typename Data::ArrayOptions f) { Q_ASSERT(d); d->flags &= ~f; }
|
||||
void setFlag(typename Data::ArrayOptions f) noexcept { Q_ASSERT(d); d->flags |= f; }
|
||||
void clearFlag(typename Data::ArrayOptions f) noexcept { Q_ASSERT(d); d->flags &= ~f; }
|
||||
typename Data::ArrayOptions detachFlags() const noexcept { return d ? d->detachFlags() : Data::DefaultAllocationFlags; }
|
||||
|
||||
Data *d_ptr() { return d; }
|
||||
Data *d_ptr() noexcept { return d; }
|
||||
|
||||
private:
|
||||
Q_REQUIRED_RESULT QPair<Data *, T *> clone(QArrayData::ArrayOptions options) const
|
||||
|
Loading…
Reference in New Issue
Block a user