Is max_size()==1 for an allocator ok for STL?

J

Juha Nieminen

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top