Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Is max_size()==1 for an allocator ok for STL?

Reply
Thread Tools

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

 
 
Juha Nieminen
Guest
Posts: n/a
 
      02-10-2011
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.)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Idea for custom thread-safe STL allocator? Brian Genisio C++ 12 01-15-2004 03:41 PM
allocator traits? Alexander Stippler C++ 4 09-03-2003 05:10 PM
How to write an allocator for the STL List in VC++ 6.0 =?ISO-8859-1?Q?Ralf_Schneewei=DF?= C++ 2 08-20-2003 11:48 PM
allocator size_type Fraser Ross C++ 1 07-31-2003 10:39 PM
[ANN] Thread-aware STL-compatible memory allocator Dan C++ 0 07-29-2003 08:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57