
At Thu, 10 Jun 2010 13:15:00 +0100, Giovanni Piero Deretta wrote:
I assume you wanted to use stack-based memory for speed, but due to the above, it would likely be slower than the equivalent heap-based integer. Especially with a good caching allocator.
In my experience, stack allocated memory easily beat heap allocation even for large buffer sizes. In the past I have used a fixed string type with a ridiculously large size for some specialized application and it outperformed the heap based string type it replaced (I didn't try to manually optimize copies away).
I assume that we're going to be using the infamous “small string optimization” at some point, which amounts to something like boost::variant< unique_ptr<char[]>, boost::array<char, 6> > right? -- Dave Abrahams BoostPro Computing http://www.boostpro.com