On Sep 24, 2008, at 11:32 AM, dariomt@gmail.com wrote:

In EASTL http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html there is something like SSO (Small String Optimization) applied to std::vector (and other STL containers)

[begin quote]
"Fixed containers are fixed-size containers with their memory stored right within the container itself. Fixed containers allocate no dynamic memory and their memory tends to be cache-friendly due to its contiguity and proximity to the container's housekeeping data. The user declares the max container size as a template parameter, and can also specify that if the container overflows that an auxiliary dynamic allocator is used.

template <typename T, size_t nodeCount, bool enableOverflow = true, 
typename Allocator overflowAllocator = EASTLAllocator>
class fixed_vector
{
...
};
[end quote]

I have tried a similar approach using some sort of fixed_buffer_with_overflow allocator, with no success. I'm not sure SSO is even possible just using an allocator with the standard containers, because I always end up with stateful allocators.

So my question is if there is something similar already in boost.

A small vector with fixed capacity has been proposed a few years ago by Synge Todo. In discussions about initial interest it was said though that people would prefer a full-featured policy-based vector instead. Synge's code is thus not in Boost, but is available under the Boost license as part of the ALPS project at http://alps.comp-phys.org/

Matthias