Boost logo

Boost Users :

Subject: [Boost-users] String, vector type with stack-allocated internal array (and dynamic array fallback)?
From: Boris Dušek (boris.dusek_at_[hidden])
Date: 2009-06-30 02:28:04


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 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