I have a custom hit class with an associated G4Allocator
. The documentation is clear that such an object must have a “constant size”:
G4Allocator
assumes that objects being allocated have all the same size for the type they represent. For this reason, classes which are handled byG4Allocator
should avoid to be used as base-classes for others.
How does this assumption apply to objects containing a std::vector
? My understanding is that the std::vector
object is fixed size; it contains a pointer to the underlying array of entities in the vector, and that array may be freed and reallocated somewhere else as the vector grows.
Is this an issue when using G4Allocator
? Should I instead use C-style arrays with a pre-set “MAXENTRIES
” dimension and “nEntries
” data member?