new int[0]
is permitted in C++ but is std::allocator<int>().allocate(0)
well defined?
More general, must all Allocators accept 0
as a parameter to allocate?
Edit:
After reading the answers I tested Visual Studio's std::allocator
: allocate(0)
gives nullptr
deallocate(nullptr, anything)
is a nop.
So using nullptr
is a good suggestion, but the standard do not demand that deallocate(nullptr, 0)
is a nop, see C++ allocator::deallocate(NULL,1) allowed?