Boost logo

Boost :

From: David Bergman (davidb_at_[hidden])
Date: 2004-05-13 12:49:45


Reece wrote:

> There is not meant to be any buffer allocation. char_string
> is a fixed-capacity string that will not write beyond the
> length of that buffer.

I implemented a fixed_string class with an "overflow" policy, acting both on
filling the string and accessing it, where I supplied four implementations,
(1) no check (well, this would not help against those buffer overflow
attacks someone mentioned...) for out-of-bounds operations, (2) just ignore
out-of-bounds, i.e., truncate long fills and ignore operations, (3) throw an
exception both on overflow fills and operations and (4) allocate a
'std::string' for the overflow (minus the size used in the union
structure...) which would not make it fixed size, just particularly
efficient for strings of a maximum fixed length.

I would welcome "overflow" policies to the static and fixed size string.

/David


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk