52template<
typename T>
struct ListBaseT :
public ListBase {
56 return this->first_ ==
nullptr;
60 bool is_single()
const
62 return this->first_ !=
nullptr && this->last_ == this->first_;
68 void clear_no_delete()
70 this->first_ =
nullptr;
71 this->last_ =
nullptr;
78 void free_no_destruct()
80 static_assert(std::is_trivially_destructible_v<T>,
81 "Items with a non-trivial destructor have to be freed separately");
82 for (
T &item : this->items_mutable()) {
85 this->first_ =
nullptr;
86 this->last_ =
nullptr;
95 for ([[maybe_unused]]
const T &item : *
this) {
104 return static_cast<T *
>(this->first_);
108 return static_cast<T *
>(this->first_);
112 return static_cast<T *
>(this->last_);
116 return static_cast<T *
>(this->last_);
118 template<
typename U>
U *first_as()
const
120 return reinterpret_cast<U *
>(this->first());
122 template<
typename U>
U *first_as()
124 return reinterpret_cast<U *
>(this->first());
126 template<
typename U>
U *last_as()
const
128 return reinterpret_cast<U *
>(this->last_);
130 template<
typename U>
U *last_as()
132 return reinterpret_cast<U *
>(this->last_);
137 ListBaseTIterator<T>
begin()
const
139 return ListBaseTIterator<T>{this->first()};
142 ListBaseTIterator<T> end()
const
145 return ListBaseTIterator<T>{
nullptr};
152 ListBaseEnumerateWrapper<T> enumerate()
154 return {this->first_};
157 ListBaseEnumerateWrapper<const T> enumerate()
const
159 return {this->first_};
163 ListBaseMutableWrapper<T> items_mutable()
165 return {this->first_};
169 ListBaseBackwardWrapper<T> items_reversed()
171 return {this->last_};
174 ListBaseBackwardWrapper<const T> items_reversed()
const
176 return {this->last_};
180 ListBaseMutableBackwardWrapper<T> items_reversed_mutable()
182 return {this->last_};
186 template<
typename OtherT>
const ListBaseT<OtherT> &
cast()
const
188 return *
reinterpret_cast<const ListBaseT<OtherT> *
>(
this);
191 template<
typename OtherT> ListBaseT<OtherT> &
cast()
193 return *
reinterpret_cast<ListBaseT<OtherT> *
>(
this);
Read Blender memory allocation and freeing.
ccl_device_inline int4 cast(const float4 a)