Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2004-06-01 16:02:55

From: John Nagle <nagle_at_[hidden]>
> I've done some cleanup on my version of fixed_string at
> This now conforms to Dunn's decision on length, i.e.
> "fixed_string<char,4> s" now has space for four characters
> plus a trailing null.


> I decided that "operator[]" had to let users reach the
> trailing null without a subscript error, so that the classic
> C idiom of a loop stopped by the trailing null
> for (i=0; s[i]; i++)

Good idea.

> would still work. Because "operator[]" can't tell a read from
> a write, this offers the possibility of overstoring the

Sure it can: just return a proxy. Assignment through the proxy
is a write and can be checked against exceeding N. Conversion of
the proxy to the character type is a read and can permit
accessing element N + 1.

> trailing null. But c_str() will always reset the trailing
> null if necessary.

Will you still need to reset the trailing null if using the

> The functions of fixed_string are now all accessable
> via fixed_string_base, as virtual functions, which was
> an ommission in the previous version.


Rob Stewart                           stewart_at_[hidden]
Software Engineer           
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at, gregod at, cpdaniel at, john at