35template<
bool CheckSelf>
36void Foam::PtrList<T>::copyPtrList(
const UPtrList<T>& list)
39 if constexpr (CheckSelf)
47 const label len = list.size();
50 PtrList<T>::resize(len);
52 for (label i = 0; i < len; ++i)
54 const T* src = list.get(i);
61 *(this->ptrs_[i]) = *src;
66 this->ptrs_[i] = src->clone().ptr();
72 delete this->ptrs_[i];
73 this->ptrs_[i] =
nullptr;
84 UPtrList<
T>(list.size())
89 for (auto iter = list.cbegin(); iter != list.cend(); ++iter)
91 this->ptrs_[i++] = (*iter).clone().ptr();
102 (this->ptrs_).free();
109template<
class... Args>
112 const label len = this->size();
116 for (label i=0; i<len; ++i)
118 const T* ptr = this->ptrs_[i];
122 cloned.
ptrs_[i] = ptr->clone(std::forward<Args>(
args)...).ptr();
133 const label oldLen = this->size();
139 else if (newLen != oldLen)
142 for (label i = newLen; i < oldLen; ++i)
144 delete this->ptrs_[i];
145 this->ptrs_[i] =
nullptr;
149 (this->ptrs_).
resize(newLen);
Non-intrusive singly-linked pointer list.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
void free()
Free memory and nullify all entries. Does not change the list size.
~PtrList()
Destructor. Frees all pointers.
constexpr PtrList() noexcept
Default construct.
void resize(const label newLen)
Adjust size of PtrList.
UPtrList(Detail::PtrListDetail< T > &&ptrs) noexcept
Low-level move construct.
label size() const noexcept
The number of entries in the list.
Detail::PtrListDetail< T > ptrs_
The list of pointers.
patchWriters resize(patchIds.size())
LPtrList< SLListBase, T > SLPtrList
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Foam::argList args(argc, argv)
#define FOAM_UNLIKELY(cond)