Boost logo

Boost Users :

Subject: Re: [Boost-users] String, vector type with stack-allocated internal array (and dynamic array fallback)?
From: Christian Schladetsch (christian.schladetsch_at_[hidden])
Date: 2009-06-30 08:02:25


Hi,

I have a library proposal called Boost.Monotonic that does exactly this.
Documentation is a work in progress, and what there is, is out of date.
However, you are welcome to dig around
https://svn.boost.org/svn/boost/sandbox/monotonic/. A good starting point is
the test suite at http://tinyurl.com/mhwn5b.

Very quickly, it is a storage system that starts on that stack (with a size
you can specify), then grows to the heap as needed. This is combined with an
allocator that can use this storage, allowing containers and strings etc to
use the stack at first, then the heap as needed.

You may also get some joy from boost::auto_buffer<> which is in the trunk,
but this can't be used as a storage area for containers or strings.

Cheers,
Christian.

2009/6/30 Boris Dušek <boris.dusek_at_[hidden]>

> Hello,
> for performance reasons, I would like not to have to have a std::wstring (1
> allocation/1 deallocation of its character array) in one routine and instead
> have a wchar_t[MAXSIZE]. But I also would like my code to be correct for
> sizes bigger than MAXSIZE.
>
> Is there some type (in boost or elsewhere, preferable for both basic_string
> and vector) that defaults to stack-allocated array of some size (preferably
> configurable by a template parameter), and in case of overflow (i.e.
> push_back or insert when it's full), would allocate a dynamically-allocated
> array? This is how it works on MSVC with their STL basic_string
> implementation, just the array size is unconfigurable (16 bytes including
> null-terminating byte). I would obviously choose the MAXSIZE so that 99.9%
> of cases are handled by the stack-allocated array.
>
> Thanks,
> Boris
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net