Hello Christian, thanks for your reply. On Tue, Jun 30, 2009 at 2:02 PM, Christian Schladetsch < christian.schladetsch@gmail.com> wrote:
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.
This is great - exactly what I have been looking for. I have checked out the
library from trunk and I am now in the process of trying it on my production
code (first I have to finally add some sane repeatable performance testing
to my project, until today I just used to manually ran a profiler and that
was it).
I want to ask a few questions though:
If I write
void some_function() {
typedef std::basic_string
2009/6/30 Boris Dušek
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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users