75 copyPtrList<false>(list);
86 list =
static_cast<T*
>(
nullptr);
91template<
class CloneArg>
95 const CloneArg& cloneArg
128template<
class... Args>
131 T* ptr =
new T(std::forward<Args>(
args)...);
178 <<
"Attempted push_back to self"
182 const label idx = this->size();
183 const label len = other.size();
187 for (label i = 0; i < len; ++i)
189 set(idx + i, other.release(i));
197template<
class... Args>
201 T* ptr =
new T(std::forward<Args>(
args)...);
208template<
class... Args>
216template<
class... Args>
224 return this->emplace_set(i, std::forward<Args>(
args)...);
243 std::unique_ptr<T>&& ptr
246 return set(i, ptr.release());
257 return set(i, ptr.release());
268 return set(i, ptr.ptr());
279 return set(i, ptr.ptr());
286 if (i < 0 || i >= this->size())
314 this->copyPtrList<true>(list);
322 this->copyPtrList<true>(list);
329 this->transfer(list);
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
T & emplace(const label i, Args &&... args)
Same as emplace_set().
void transfer(PtrList< T > &list)
Transfer into this list and annul the argument list.
const CloudFunctionObject< CloudType > * set(const label i) const
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
autoPtr< T > release(const label i)
Release ownership of the pointer at the given position.
void push_back(T *ptr)
Append an element to the end of the list.
T & emplace_back(Args &&... args)
Construct and append an element to the end of the list, return reference to the new list element.
void operator=(const UPtrList< T > &list)
Copy assignment.
T & emplace_set(const label i, Args &&... args)
Construct and set a new element at given position, (discard old element at that location).
T & try_emplace(const label i, Args &&... args)
Like emplace_set() but will not overwrite an occupied (non-null) location.
void free()
Free memory and nullify all entries. Does not change the list size.
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
constexpr PtrList() noexcept
Default construct.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
void push_back(T *ptr)
Append an element to the end of the list.
UPtrList(Detail::PtrListDetail< T > &&ptrs) noexcept
Low-level move construct.
const T * get(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
label size() const noexcept
The number of entries in the list.
void resize_null(const label newLen)
Set the list to the given size and set all entries to nullptr.
void transfer(UPtrList< T > &list)
Transfer contents into this list and annul the argument.
Detail::PtrListDetail< T > ptrs_
The list of pointers.
void clear()
Set list size to zero.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A class for managing references or pointers (no reference counting).
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
A class for managing temporary objects.
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
patchWriters resize(patchIds.size())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Foam::argList args(argc, argv)
#define FOAM_UNLIKELY(cond)