41 #ifndef LIB_REF_ARRAY_IMPL_H 42 #define LIB_REF_ARRAY_IMPL_H 59 template<
class B,
class IM = B>
63 typedef vector<IM>
const& Tab;
72 virtual size_t size()
const 77 virtual B
const& operator[] (
size_t i)
const 89 template<
class B,
class IM = B>
95 typedef vector<IM> Vect;
96 typedef typename Vect::size_type Size_t;
97 typedef typename Vect::value_type Val_t;
101 RefArrayVector(Size_t n, Val_t
const& v = Val_t()) : Vect(n,v), Wrap((Vect&)*
this) {}
102 RefArrayVector(Vect
const& ref) : Vect(ref), Wrap((Vect&)*
this) {}
105 using Wrap::operator[];
116 template<
class B,
size_t n,
class IM = B>
120 char storage_[n*
sizeof(IM)];
125 : array_ (reinterpret_cast<IM*> (&storage_))
131 new(&array_[i++]) IM();
133 catch(...) { cleanup(i);
throw; }
138 : array_ (reinterpret_cast<IM*> (&storage_))
144 factory(&array_[i++]);
146 catch(...) { cleanup(i-1);
throw; }
152 void cleanup(
size_t top=n) noexcept
154 while (top) array_[--top].~IM();
160 virtual size_t size()
const 165 virtual B
const& operator[] (
size_t i)
const 167 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...