59 #ifndef LIB_LINKED_ELEMENTS_H 60 #define LIB_LINKED_ELEMENTS_H 74 using LERR_(INDEX_BOUNDS);
78 namespace linked_elements {
89 typedef void* CustomAllocator;
104 template<
class TY,
typename...ARGS>
108 return *
new TY (std::forward<ARGS> (args)...);
128 typedef void* CustomAllocator;
139 template<
class TY,
typename...ARGS>
143 static_assert (
"NoOwnership allocation strategy can not allocate elements");
151 #ifdef LIB_ALLOCATION_CLUSTER_H 162 struct UseAllocationCluster
166 CustomAllocator cluster_;
170 UseAllocationCluster (CustomAllocator clu)
188 template<
class TY,
typename...ARGS>
192 return cluster_.create<TY> (std::forward<ARGS> (args)...);
196 #endif //(End)if lib/allocation-cluster.hpp was included 269 pushAll (std::forward<IT> (
elements));
273 WARN (progress,
"Failure while populating LinkedElements list. " 274 "All elements will be discarded");
316 template<
typename TY>
334 template<
class TY =N,
typename...ARGS>
338 return push (ALO::template create<TY> (std::forward<ARGS> (args)...));
355 head_->next =
nullptr;
371 operator[] (
size_t index)
const 381 throw error::Logic (
"Attempt to access element beyond the end of LinkedElements list" 382 , LERR_(INDEX_BOUNDS));
392 REQUIRE (head_,
"NIL");
393 return *(unConst(
this)->head_);
457 return * unConst(
this)->node;
463 return il.node == ir.node;
LinkedElements & reverse()
Mutate the complete list to change the order of elements.
IterQueue< T > elements(T const &elm)
convenience free function to build an iterable sequence
TY & emplace(ARGS &&...args)
prepend object of type TY, forwarding ctor args
Iteration is just following the single linked list.
void pushAll(IT elements)
convenience shortcut to add all the elements yielded by the given Lumiera Forward Iterator ...
#define ERROR_LOG_AND_IGNORE(_FLAG_, _OP_DESCR_)
convenience shortcut for a sequence of catch blocks just logging and consuming an error...
Intrusive single linked list, possibly taking ownership of node elements.
Helper template(s) for creating Lumiera Forward Iterators.
Types marked with this mix-in may be moved but not copied.
bool operator==(PtrDerefIter< I1 > const &il, PtrDerefIter< I2 > const &ir)
Supporting equality comparisons...
TY & create(ARGS &&...args)
this policy creates new elements simply by heap allocation
LinkedElements(IT &&elements)
creating a LinkedElements list in RAII-style:
Implementation namespace for support and library code.
Derived specific exceptions within Lumiera's exception hierarchy.
void iterNext()
Iteration-logic: switch to next position.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Another Lumiera Forward Iterator building block, based on incorporating a state type right into the i...
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
TY & push(TY &elm)
accept the given element and prepend it to the list of elements; depending on the allocation policy...
< allocation policies for the LinkedElements list container
Lumiera error handling (C++ interface).
A pile of objects sharing common allocation and lifecycle.
bool checkPoint() const
Iteration-logic: detect iteration end.
void destroy(void *)
this policy doesn't take ownership and thus never discards anything
LinkedElements(typename ALO::CustomAllocator allo)
void destroy(X *elm)
this policy discards elements by deallocating them from heap
Policy for LinkedElements: never create or destroy any elements, only allow to add already existing n...