What happens if you call append() with two different allocators? Or if you deinit() with a different allocator than the one that actually handled the memory?
What happens if you call append() with two different allocators? Or if you deinit() with a different allocator than the one that actually handled the memory?
It also helps devirtualization, as the most common case is threading a single allocator through your application (with the occasion Arena allocator wrapping it for grouped allocations). When the Allocator interface is stored in the container, it's harder for the optimizer to prove it hasn't changed.
> What happens if you call append() with two different allocators? Or if you deinit() with a different allocator than the one that actually handled the memory?
It's undefined behaviour, but I've never seen it be an issue in practice. Expanding on what I mentioned above, it's typical for only a single allocator to be used for long live objects throughout the entire program. Arena allocators are used for grouped allocations, and tend to have a well defined scope, so it's obvious where deallocation occurs. FixedBufferAllocator also tends to be used in the same limited scope.