73 std::function<void(TAR*)> dtor_{};
78 installDestructor (FUN&& dtor)
80 dtor_ = std::forward<FUN> (dtor);
87 auto destructionFun = std::move(dtor_);
89 destructionFun (target());
93 bool isArmed()
const {
return bool(dtor_); }
94 auto getDtor()
const {
return dtor_; }
95 void destroy() { target()->~TAR(); }
96 TAR* target() {
return static_cast<TAR*
>(
this); }
108 ArrayBucket (
size_t storageSize,
size_t buffStart,
size_t elmSize =
sizeof(I))
111 , buffSiz{storageSize - buffStart}
112 , buffOffset{buffStart}
115 using Deleter = std::function<void(ArrayBucket*)>;
122 static constexpr
size_t storageOffset =
sizeof(
ArrayBucket);
123 size_t getAllocSize()
const {
return buffOffset +buffSiz; }
130 return reinterpret_cast<std::byte*
>(
this) + buffOffset;
137 std::byte* elm = storage() + (idx * spread);
138 ENSURE (storage() <= elm and elm < storage()+buffSiz);
139 return * std::launder (reinterpret_cast<I*> (elm));
168 try {
if (data_) data_->destroy(); }
174 std::swap (data_, rr.data_);
178 std::swap (data_, rr.data_);
185 return data_? data_->cnt : 0;
195 operator[] (
size_t idx)
198 return data_->subscript (idx);
202 operator[] (
size_t idx)
const 204 return const_cast<Several&
>(*this).operator[] (idx);
207 I& front() {
return operator[] (0); }
208 I& back() {
return operator[] (data_? data_->cnt-1 : 0); }
218 friend auto begin (
Several& svl) {
return svl.begin();}
219 friend auto end (
Several& svl) {
return svl.end(); }
220 friend auto begin (
Several const& svl) {
return svl.begin();}
221 friend auto end (
Several const& svl) {
return svl.end(); }
228 return data_? data_->spread :
sizeof(I);
232 storageBuffSiz()
const 234 return data_? data_->buffSiz : 0;
238 hasReserve (
size_t requiredSize,
size_t newElms =1)
const 240 if (requiredSize < spread())
241 requiredSize = spread();
242 size_t extraSize{requiredSize * newElms};
243 if (requiredSize > spread())
244 extraSize += (requiredSize - spread())*size();
246 and data_->buffSiz >= size()*spread() + extraSize;
Types marked with this mix-in may be moved and move-assigned.
I & subscript(size_t idx)
perform unchecked access into the storage area
#define ERROR_LOG_AND_IGNORE(_FLAG_, _OP_DESCR_)
convenience shortcut for a sequence of catch blocks just logging and consuming an error...
Metadata record placed immediately before the data storage.
Implementation namespace for support and library code.
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Abstraction: Fixed array of elements.
Iterator-style access handle to a referred container with subscript index.
Subscript-index based access to a container, packaged as iterator.
std::byte * storage()
data storage area starts immediately behind the ArrayBucket