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

Discussion in 'C++' started by Juha Nieminen, Feb 10, 2011.

  1. 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.)
     
    Juha Nieminen, Feb 10, 2011
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Goodsell

    Exceeding container::max_size()?

    Kevin Goodsell, Apr 3, 2004, in forum: C++
    Replies:
    1
    Views:
    389
    Victor Bazarov
    Apr 4, 2004
  2. alexey_m
    Replies:
    2
    Views:
    342
    =?ISO-8859-1?Q?Stefan_N=E4we?=
    Dec 22, 2005
  3. t

    max_size()

    t, Oct 2, 2007, in forum: C++
    Replies:
    4
    Views:
    426
    James Kanze
    Oct 3, 2007
  4. Sarath
    Replies:
    2
    Views:
    631
    Knockr
    Aug 19, 2009
  5. Great Deals
    Replies:
    1
    Views:
    241
    laura fairhead
    Oct 1, 2003
Loading...

Share This Page