I have written an allocator which can allocate only one element at a
time (in other words, the only valid parameter for allocate() is 1).
Hence the correct return value of max_size() is 1. This has worked well
for std::list, std::set and std::map.
However, I have been notified that Microsoft's implementation of STL
(at least with some versions of their compiler) throws an assertion failure
if max_size() of an allocator returns such a small value.
I was wondering what the standard says about this. Does the standard
allow std::list, std::set and std::map to demand being able to allocate
more than one element at a time, or is Microsoft's implementation being
needlessly picky?
(Of course if the standard allows this, then it simply means that this
allocator cannot be used with Microsoft's implementation of the STL.)
|