The first line from cpp reference says 'The std::allocator class template is the default Allocator used by all standard library containers if no user-specified allocator is provided...' From the given example I can see that it's used to do some memory allocation based on type:
std::allocator<int> a1; // default allocator for ints
int* a = a1.allocate(1); // space for one int
a1.construct(a, 7); // construct the int
std::cout << a[0] << '\n';
a1.deallocate(a, 1); // deallocate space for one int
However I can still do something similar with:
auto a = std::make_unique<int>(7); // single int usage
and a some std
container if I want multiple ints with contiguous access.
So when and why do I need std::allocator
?