35 template<
bool CheckSelf>
39 if constexpr (CheckSelf)
47 const label len = list.
size();
52 for (label i = 0; i < len; ++i)
54 if (
const T* src = list.get(i); src)
59 *(this->ptrs_[i]) = *src;
64 this->ptrs_[i] = src->clone().ptr();
70 delete this->ptrs_[i];
71 this->ptrs_[i] =
nullptr;
82 UPtrList<
T>(list.size())
87 for (
auto iter = list.cbegin(); iter != list.cend(); ++iter)
89 this->ptrs_[i++] = (*iter).clone().ptr();
100 (this->ptrs_).free();
107 template<
class... Args>
110 const label len = this->size();
114 for (label i=0; i<len; ++i)
116 if (
const T* ptr = this->ptrs_[i]; ptr)
118 cloned.
ptrs_[i] = ptr->clone(std::forward<Args>(
args)...).ptr();
133 else if (
const label oldLen = this->size(); newLen != oldLen)
136 for (label i = newLen; i < oldLen; ++i)
138 delete this->ptrs_[i];
139 this->ptrs_[i] =
nullptr;
143 (this->ptrs_).
resize(newLen);
patchWriters resize(patchIds.size())
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
~PtrList()
Destructor. Frees all pointers.
constexpr PtrList() noexcept
Default construct.
label size() const noexcept
The number of entries in the list.
#define FOAM_UNLIKELY(cond)
Non-intrusive singly-linked pointer list.
void resize(const label newLen)
Adjust size of PtrList.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Foam::argList args(argc, argv)
Detail::PtrListDetail< T > ptrs_
The list of pointers.