69 list =
static_cast<T*
>(
nullptr);
74 template<
class CloneArg>
78 const CloneArg& cloneArg
105 (this->ptrs_).free();
111 template<
class... Args>
114 T* ptr =
new T(std::forward<Args>(
args)...);
161 <<
"Attempted push_back to self" 165 const label idx = this->size();
166 const label len = other.size();
170 for (label i = 0; i < len; ++i)
172 set(idx + i, other.release(i));
180 template<
class... Args>
183 (void) this->release(i);
184 T* ptr =
new T(std::forward<Args>(
args)...);
191 template<
class... Args>
194 return this->emplace_set(i, std::forward<Args>(
args)...);
199 template<
class... Args>
207 return this->emplace_set(i, std::forward<Args>(
args)...);
226 std::unique_ptr<T>&& ptr
229 return set(i, ptr.release());
240 return set(i, ptr.release());
251 return set(i, ptr.
ptr());
262 return set(i, ptr.ptr());
269 if (i < 0 || i >= this->size())
286 (this->ptrs_).free();
296 this->transfer(list);
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
patchWriters resize(patchIds.size())
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
A class for managing references or pointers (no reference counting)
T & emplace_back(Args &&... args)
Construct and append an element to the end of the list, return reference to the new list element...
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
constexpr PtrList() noexcept
Default construct.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void free()
Free memory and nullify all entries. Does not change the list size.
void operator=(const PtrList< T > &list)
Copy assignment.
T & emplace(const label i, Args &&... args)
Same as emplace_set()
T & try_emplace(const label i, Args &&... args)
Like emplace_set() but will not overwrite an occupied (non-null) location.
T & emplace_set(const label i, Args &&... args)
Construct and set a new element at given position, (discard old element at that location).
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
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.
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
void transfer(PtrList< T > &list)
Transfer into this list and annul the argument list.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
T * ptr() const
Return managed pointer for reuse, or clone() the object reference.
A class for managing temporary objects.
Foam::argList args(argc, argv)