Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-06-16 13:00:57

Is this of any interest for boost? Some library implementations (for
instance STLport) return a value of container::max_size that doesn't
depend on the corresponding allocator. For instance, for vector<T>
STLport returns:

   size_type(-1) / sizeof(T)

As a result, if one uses his own allocator which has, say, a maximum
size = 255, there's no hope that the user of vector can see the limit.
Would something like this be ok?

  template <typename T>
  typename T::size_type max_size(const T& t)
    // Note that there's no requirement for a container's
    // size_type to match its allocator size_type.
    // There is for basic_string.
    typedef typename T::allocator_type allocator_type;

    const typename allocator_type::size_type max_alloc =
    const typename T::size_type max_cont = t.max_size();

    return max_alloc < max_cont? max_alloc : max_cont;



Boost list run by bdawes at, gregod at, cpdaniel at, john at