4#ifndef QARRAYDATAPOINTER_H
5#define QARRAYDATAPOINTER_H
7#include <QtCore/qarraydataops.h>
8#include <QtCore/qcontainertools_impl.h>
10#include <QtCore/q20functional.h>
11#include <QtCore/q20memory.h>
25 std::is_arithmetic<T>::value || std::is_pointer<T>::value || std::is_enum<T>::value
28 typedef typename std::conditional<pass_parameter_by_value, T, const T &>::type
parameter_type;
59 return {
nullptr,
const_cast<T *
>(rawData),
length };
82 return *
static_cast<DataOps *
>(
this);
87 return static_cast<DataOps *
>(
this);
92 return *
static_cast<const DataOps *
>(
this);
97 return static_cast<const DataOps *
>(
this);
103 (*this)->destroyAll();
114 const T *
data() const noexcept {
return ptr; }
155 if (
sizeof(T) !=
sizeof(
X)) {
160 auto optr =
reinterpret_cast<X *
>(std::exchange(
ptr,
nullptr));
161 return { od, optr, std::exchange(
size, 0) };
191 bool readjusted =
false;
317 template <
typename InputIterator,
typename Projection = q20::
identity>
318 void assign(InputIterator
first, InputIterator last, Projection proj = {})
321 constexpr bool IsFwdIt = std::is_convertible_v<
322 typename std::iterator_traits<InputIterator>::iterator_category,
323 std::forward_iterator_tag>;
324 constexpr bool IsIdentity = std::is_same_v<Projection, q20::identity>;
326 if constexpr (IsFwdIt) {
342 const auto prependBufferEnd =
begin();
344 if constexpr (!std::is_nothrow_constructible_v<T,
decltype(std::invoke(proj, *
first))>) {
349 (*this)->truncate(0);
355 auto dst = capacityBegin;
356 const auto dend =
end();
366 if (
dst == prependBufferEnd) {
372 std::destroy(prependBufferEnd, dend);
385 std::destroy(
dst, dend);
389 if constexpr (IsFwdIt && IsIdentity) {
392 }
else if constexpr (IsFwdIt && !IsIdentity
393 && std::is_nothrow_constructible_v<T,
decltype(std::invoke(proj, *
first))>) {
399 (*this)->emplace(
size, std::invoke(proj, *
first));
400 }
while (++
first != last);
456 const bool valid =
header !=
nullptr && dataPtr !=
nullptr;
471 return lhs.data() == rhs.data() && lhs.size == rhs.size;
476 return lhs.data() != rhs.data() || lhs.size != rhs.size;
497#define Q_ARRAY_LITERAL(Type, ...) \
498 ([]() -> QArrayDataPointer<Type> { \
499 static Type const data[] = { __VA_ARGS__ }; \
500 return QArrayDataPointer<Type>::fromRawData(const_cast<Type *>(data), std::size(data)); \
void swap(QPixmap &other) noexcept
Combined button and popup list for selecting options.
static constexpr bool q_points_into_range(const T *p, const T *b, const T *e, Cmp less={}) noexcept
void q_relocate_overlap_n(T *first, N n, T *d_first)
T * construct_at(T *ptr, Args &&... args)
std::pair< T1, T2 > QPair
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMax(const T &a, const T &b)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
Q_CHECK_PTR(a=new int[80])
Q_NODISCARD_CTOR constexpr QArrayDataPointer(Data *header, T *adata, qsizetype n=0) noexcept
friend bool operator==(const QArrayDataPointer &lhs, const QArrayDataPointer &rhs) noexcept
void setFlag(typename Data::ArrayOptions f) noexcept
void detachAndGrow(QArrayData::GrowthPosition where, qsizetype n, const T **data, QArrayDataPointer *old)
bool isShared() const noexcept
void relocate(qsizetype offset, const T **data=nullptr)
Q_NODISCARD_CTOR QArrayDataPointer(QPair< QTypedArrayData< T > *, T * > adata, qsizetype n=0) noexcept
bool isNull() const noexcept
const T * data() const noexcept
const T * constBegin() const noexcept
qsizetype freeSpaceAtBegin() const noexcept
const DataOps & operator*() const noexcept
Q_NEVER_INLINE void reallocateAndGrow(QArrayData::GrowthPosition where, qsizetype n, QArrayDataPointer *old=nullptr)
void detach(QArrayDataPointer *old=nullptr)
bool needsDetach() const noexcept
bool isSharedWith(const QArrayDataPointer &other) const noexcept
qsizetype allocatedCapacity() noexcept
const DataOps * operator->() const noexcept
const T * constEnd() const noexcept
std::conditional< pass_parameter_by_value, T, constT & >::type parameter_type
void setBegin(T *begin) noexcept
QArrayDataPointer< X > reinterpreted() &&
DataOps * operator->() noexcept
Q_NODISCARD_CTOR constexpr QArrayDataPointer() noexcept
qsizetype freeSpaceAtEnd() const noexcept
Q_NODISCARD_CTOR QArrayDataPointer(const QArrayDataPointer &other) noexcept
void swap(QArrayDataPointer &other) noexcept
const T * begin() const noexcept
const Data::ArrayOptions flags() const noexcept
qsizetype constAllocatedCapacity() const noexcept
void clear() noexcept(std::is_nothrow_destructible< T >::value)
const T * end() const noexcept
bool tryReadjustFreeSpace(QArrayData::GrowthPosition pos, qsizetype n, const T **data=nullptr)
friend bool operator!=(const QArrayDataPointer &lhs, const QArrayDataPointer &rhs) noexcept
QArrayDataPointer & operator=(const QArrayDataPointer &other) noexcept
static QArrayDataPointer allocateGrow(const QArrayDataPointer &from, qsizetype n, QArrayData::GrowthPosition position)
Q_NODISCARD_CTOR QArrayDataPointer(QArrayDataPointer &&other) noexcept
@ pass_parameter_by_value
bool isMutable() const noexcept
qsizetype detachCapacity(qsizetype newSize) const noexcept
void clearFlag(typename Data::ArrayOptions f) noexcept
static Q_NODISCARD_CTOR QArrayDataPointer fromRawData(const T *rawData, qsizetype length) noexcept
void assign(InputIterator first, InputIterator last, Projection proj={})
qsizetype detachCapacity(qsizetype newSize) const noexcept
bool needsDetach() const noexcept
bool deref() noexcept
Returns false if deallocation is necessary.
bool isShared() const noexcept
qsizetype constAllocatedCapacity() const noexcept
qsizetype allocatedCapacity() noexcept
bool ref() noexcept
Returns true if sharing took place.
static T * dataStart(QArrayData *data, qsizetype alignment) noexcept
static QPair< QTypedArrayData *, T * > allocate(qsizetype capacity, AllocationOption option=QArrayData::KeepSize)
void moveAppend(T *b, T *e)
void copyAppend(const T *b, const T *e)