8#include <QtCore/qarraydata.h>
9#include <QtCore/qcontainertools_impl.h>
10#include <QtCore/qnamespace.h>
30 static_assert (std::is_nothrow_destructible_v<T>,
"Types with throwing destructors are not supported in Qt containers.");
33 typedef QTypedArrayData<T>
Data;
48 T *where = this->
end();
50 const T *e = this->
end();
65 ::memcpy(
static_cast<void *
>(this->
end()),
static_cast<const void *
>(
b), (e -
b) *
sizeof(T));
66 this->
size += (e -
b);
76 T *where = this->
end();
99 Q_ASSERT(this->
d->ref_.loadRelaxed() == 0);
110 T *insertionPoint = this->
ptr + where;
112 if (where < this->
size)
113 ::memmove(
static_cast<void *
>(insertionPoint +
n),
static_cast<void *
>(insertionPoint), (this->size - where) *
sizeof(T));
120 return insertionPoint;
125 typename Data::GrowthPosition
pos = Data::GrowsAtEnd;
126 if (this->
size != 0 &&
i == 0)
127 pos = Data::GrowsAtBeginning;
135 ::memcpy(
static_cast<void *
>(where),
static_cast<const void *
>(
data),
n *
sizeof(T));
142 typename Data::GrowthPosition
pos = Data::GrowsAtEnd;
143 if (this->
size != 0 &&
i == 0)
144 pos = Data::GrowsAtBeginning;
155 template<
typename... Args>
161 new (this->
end()) T(std::forward<Args>(
args)...);
166 new (this->
begin() - 1) T(std::forward<Args>(
args)...);
172 T tmp(std::forward<Args>(
args)...);
174 if (this->
size != 0 &&
i == 0)
180 new (where) T(std::move(tmp));
195 if (
b == this->
begin() && e != this->
end()) {
197 }
else if (e != this->
end()) {
198 ::memmove(
static_cast<void *
>(
b),
static_cast<void *
>(e),
199 (
static_cast<T *
>(this->
end()) - e) *
sizeof(T));
219 template <
typename Predicate>
228 auto it = std::remove_if(this->
begin(),
end, pred);
235 const auto end = this->
end();
242 auto dest =
other.begin();
244 dest = std::uninitialized_copy(
begin,
it, dest);
246 other.size = std::distance(
other.data(), dest);
258 std::for_each(ranges.begin(), ranges.end(), [&
it](
const auto &
span) {
259 it = std::copy(span.begin, span.end, it);
270 ::memcpy(
static_cast<void *
>(
b++),
static_cast<const void *
>(&
t),
sizeof(T));
273 bool compare(
const T *begin1,
const T *begin2,
size_t n)
const
279 return ::memcmp(begin1, begin2,
n *
sizeof(T)) == 0;
281 const T *end1 = begin1 +
n;
282 while (begin1 != end1) {
283 if (*begin1 == *begin2) {
296 auto pair = Data::reallocateUnaligned(this->
d, this->
ptr, alloc,
option);
299 this->
d = pair.first;
300 this->
ptr = pair.second;
308 static_assert (std::is_nothrow_destructible_v<T>,
"Types with throwing destructors are not supported in Qt containers.");
311 typedef QTypedArrayData<T>
Data;
324 T *
const b = this->
begin();
326 new (b + this->
size) T;
327 }
while (++this->
size != newSize);
374 new (
data + this->
size) T(std::move(*
b));
386 std::destroy(this->
begin() + newSize, this->
end());
387 this->
size = newSize;
396 Q_ASSERT(this->
d->ref_.loadRelaxed() == 0);
398 std::destroy(this->
begin(), this->
end());
510 new (
end) T(std::move(
t));
515 new (
end) T(std::move(*(
end - 1)));
530 const bool growsAtBegin = this->
size != 0 &&
i == 0;
531 const auto pos = growsAtBegin ? Data::GrowsAtBeginning : Data::GrowsAtEnd;
556 const bool growsAtBegin = this->
size != 0 &&
i == 0;
557 const auto pos = growsAtBegin ? Data::GrowsAtBeginning : Data::GrowsAtEnd;
576 template<
typename... Args>
582 new (this->
end()) T(std::forward<Args>(
args)...);
587 new (this->
begin() - 1) T(std::forward<Args>(
args)...);
593 T tmp(std::forward<Args>(
args)...);
594 const bool growsAtBegin = this->
size != 0 &&
i == 0;
595 const auto pos = growsAtBegin ? Data::GrowsAtBeginning : Data::GrowsAtEnd;
601 new (this->
begin() - 1) T(std::move(tmp));
621 if (
b == this->
begin() && e != this->
end()) {
624 const T *
const end = this->
end();
651 (this->
end() - 1)->~T();
665 bool compare(
const T *begin1,
const T *begin2,
size_t n)
const
667 const T *end1 = begin1 +
n;
668 while (begin1 != end1) {
669 if (*begin1 == *begin2) {
684 static_assert (std::is_nothrow_destructible_v<T>,
"Types with throwing destructors are not supported in Qt containers.");
687 typedef QTypedArrayData<T>
Data;
707 if constexpr (!std::is_nothrow_copy_constructible_v<T>) {
720 T *insertionPoint =
data->ptr +
pos;
726 return insertionPoint;
755 new (where) T(std::move(
t));
765 const bool growsAtBegin = this->
size != 0 &&
i == 0;
766 const auto pos = growsAtBegin ? Data::GrowsAtBeginning : Data::GrowsAtEnd;
791 const bool growsAtBegin = this->
size != 0 &&
i == 0;
792 const auto pos = growsAtBegin ? Data::GrowsAtBeginning : Data::GrowsAtEnd;
811 template<
typename... Args>
817 new (this->
end()) T(std::forward<Args>(
args)...);
822 new (this->
begin() - 1) T(std::forward<Args>(
args)...);
828 T tmp(std::forward<Args>(
args)...);
829 const bool growsAtBegin = this->
size != 0 &&
i == 0;
830 const auto pos = growsAtBegin ? Data::GrowsAtBeginning : Data::GrowsAtEnd;
835 new (this->
begin() - 1) T(std::move(tmp));
858 if (
b == this->
begin() && e != this->
end()) {
860 }
else if (e != this->
end()) {
861 memmove(
static_cast<void *
>(
b),
static_cast<const void *
>(e), (
static_cast<const T *
>(this->
end()) - e)*
sizeof(T));
868 auto pair = Data::reallocateUnaligned(this->
d, this->
ptr, alloc,
option);
871 this->
d = pair.first;
872 this->
ptr = pair.second;
876template <
class T,
class =
void>
879 typedef QGenericArrayOps<T>
Type;
884 typename
std::enable_if<
885 !QTypeInfo<T>::isComplex && QTypeInfo<T>::isRelocatable
893 typename
std::enable_if<
894 QTypeInfo<T>::isComplex && QTypeInfo<T>::isRelocatable
897 typedef QMovableArrayOps<T>
Type;
904 using Data = QTypedArrayData<T>;
909 using Self = QCommonArrayOps<T>;
917 template<
typename It>
926#if __cplusplus >= 202002L && defined(__cpp_concepts) && defined(__cpp_lib_concepts)
927 constexpr bool canUseCopyAppend =
928 std::contiguous_iterator<It> &&
930 std::remove_cv_t<typename std::iterator_traits<It>::value_type>,
933 if constexpr (canUseCopyAppend) {
934 this->
copyAppend(std::to_address(
b), std::to_address(e));
939 for (; b != e; ++
iter, ++
b) {
972 T *
const b = this->
begin();
976 if constexpr (std::is_constructible_v<T, Qt::Initialization>)
980 }
while (++this->
size != newSize);
QSet< QString >::iterator it
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
typename std::enable_if< std::is_convertible< typename std::iterator_traits< Iterator >::iterator_category, std::forward_iterator_tag >::value, bool >::type IfIsForwardIterator
T * q_uninitialized_remove_copy_if(T *first, T *last, T *out, Predicate &pred)
SlotObjUniquePtr copy(const SlotObjUniquePtr &other) noexcept
constexpr Initialization Uninitialized
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter * iter
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLsizei GLfloat distance
GLsizei GLsizei GLchar * source
GLenum GLenum GLsizei void GLsizei void void * span
Q_CHECK_PTR(a=new int[80])
std::uniform_real_distribution dist(1, 2.5)
[2]
void detachAndGrow(QArrayData::GrowthPosition where, qsizetype n, const T **data, QArrayDataPointer *old)
bool isShared() const noexcept
qsizetype freeSpaceAtBegin() const noexcept
void detach(QArrayDataPointer *old=nullptr)
bool needsDetach() const noexcept
qsizetype allocatedCapacity() noexcept
std::conditional< pass_parameter_by_value, T, constT & >::type parameter_type
Q_NODISCARD_CTOR constexpr QArrayDataPointer() noexcept
qsizetype freeSpaceAtEnd() const noexcept
void swap(QArrayDataPointer &other) noexcept
bool isMutable() const noexcept
QMovableArrayOps< T > Type
QGenericArrayOps< T > Type
void appendUninitialized(qsizetype newSize)
QArrayDataPointer< T > DataPointer
typename QArrayOpsSelector< T >::Type Base
QTypedArrayData< T > Data
QCommonArrayOps< T > Self
void appendIteratorRange(It b, It e, QtPrivate::IfIsForwardIterator< It >=true)
void growAppend(const T *b, const T *e)
typename Base::parameter_type parameter_type
void insert(qsizetype pos, const T &t, qsizetype n)
Inserter(QArrayDataPointer< T > *d)
void insertOne(qsizetype pos, T &&t)
qsizetype sourceCopyConstruct
QArrayDataPointer< T > * data
void setup(qsizetype pos, qsizetype n)
void insert(qsizetype pos, const T *source, qsizetype n)
qsizetype sourceCopyAssign
void truncate(size_t newSize)
void appendInitialize(qsizetype newSize)
void insert(qsizetype i, qsizetype n, parameter_type t)
QArrayDataPointer< T >::parameter_type parameter_type
void moveAppend(T *b, T *e)
QTypedArrayData< T > Data
void emplace(qsizetype i, Args &&... args)
void copyAppend(const T *b, const T *e)
void eraseFirst() noexcept
QArrayDataPointer< T > DataPointer
void eraseLast() noexcept
void assign(T *b, T *e, parameter_type t)
void erase(T *b, qsizetype n)
bool compare(const T *begin1, const T *begin2, size_t n) const
void insert(qsizetype i, const T *data, qsizetype n)
void copyAppend(qsizetype n, parameter_type t)
void insertOne(qsizetype pos, T &&t)
void insert(qsizetype pos, const T &t, qsizetype n)
T * displace(qsizetype pos, qsizetype n)
void insert(qsizetype pos, const T *source, qsizetype n)
Inserter(QArrayDataPointer< T > *d)
QArrayDataPointer< T > * data
QTypedArrayData< T > Data
void reallocate(qsizetype alloc, QArrayData::AllocationOption option)
void insert(qsizetype i, const T *data, qsizetype n)
void emplace(qsizetype i, Args &&... args)
QGenericArrayOps< T >::parameter_type parameter_type
QArrayDataPointer< T > DataPointer
void erase(T *b, qsizetype n)
void insert(qsizetype i, qsizetype n, parameter_type t)
void moveAppend(T *b, T *e) noexcept
void eraseFirst() noexcept
void appendInitialize(qsizetype newSize) noexcept
QArrayDataPointer< T >::parameter_type parameter_type
void copyRanges(std::initializer_list< Span > ranges)
void erase(T *b, qsizetype n)
void eraseLast() noexcept
T * createHole(QArrayData::GrowthPosition pos, qsizetype where, qsizetype n)
void insert(qsizetype i, const T *data, qsizetype n)
void truncate(size_t newSize) noexcept
void emplace(qsizetype i, Args &&... args)
qsizetype eraseIf(Predicate pred)
void assign(T *b, T *e, parameter_type t) noexcept
void copyAppend(const T *b, const T *e) noexcept
void copyAppend(qsizetype n, parameter_type t) noexcept
bool compare(const T *begin1, const T *begin2, size_t n) const
void reallocate(qsizetype alloc, QArrayData::AllocationOption option)
void insert(qsizetype i, qsizetype n, parameter_type t)
QArrayDataPointer< T > DataPointer
QTypedArrayData< T > Data
void destroyAll() noexcept