How memory is allocated by a container depends entirely on the type of container, and as a result, an allocator must be able to support different allocation types, such as the following:
- All allocations by an allocator must be contiguous in memory. There is no requirement for one allocation to be contiguous in memory with another allocation, but each individual allocation must be contiguous.
- An allocator must be able to allocate more than one element in a single allocation. This can sometimes be problematic depending on the allocator.
To explore these properties, let's use the following example:
template<typename T>class myallocator{public: using value_type = T; using pointer = T *; using size_type = std::size_t; ...