If allocators are stateless in C++, why are functions not used to allocate memory instead?
The default std::allocator class is stateless in C++. This means any instance of an std::allocator can deallocate memory allocated by another std::allocator instance. What is then the point of having instances of allocators to allocate memory? For instance, why is memory allocated like this: allocator<T> alloc, alloc2; T* buffer = alloc.allocate(42); alloc2.deallocate(buffer); When functions could… Read More If allocators are stateless in C++, why are functions not used to allocate memory instead?