34 #ifndef LIB_REF_ARRAY_IMPL_H 35 #define LIB_REF_ARRAY_IMPL_H 52 template<
class B,
class IM = B>
56 typedef vector<IM>
const& Tab;
65 virtual size_t size()
const 70 virtual B
const& operator[] (
size_t i)
const 82 template<
class B,
class IM = B>
88 typedef vector<IM> Vect;
89 typedef typename Vect::size_type Size_t;
90 typedef typename Vect::value_type Val_t;
94 RefArrayVector(Size_t n, Val_t
const& v = Val_t()) : Vect(n,v), Wrap((Vect&)*
this) {}
98 using Wrap::operator[];
109 template<
class B,
size_t n,
class IM = B>
113 char storage_[n*
sizeof(IM)];
118 : array_ (reinterpret_cast<IM*> (&storage_))
124 new(&array_[i++]) IM();
126 catch(...) { cleanup(i);
throw; }
131 : array_ (reinterpret_cast<IM*> (&storage_))
137 factory(&array_[i++]);
139 catch(...) { cleanup(i-1);
throw; }
145 void cleanup(
size_t top=n) noexcept
147 while (top) array_[--top].~IM();
153 virtual size_t size()
const 158 virtual B
const& operator[] (
size_t i)
const 160 REQUIRE (i < size());
Abstraction: Array of const references.
This header is for including and configuring NoBug.
Implementation namespace for support and library code.
RefArray implementation based on a fixed size array, i.e.
Abstraction interface: array-like access by subscript.
RefArrayTable(FAC &factory)
This variation of the wrapper actually is a vector, but can act as a RefArray.
Wrap a vector holding objects of a subtype and provide array-like access using the interface type...