
From: John Nagle <nagle@animats.com>
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.
Good.
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 proxy?
The functions of fixed_string are now all accessable via fixed_string_base, as virtual functions, which was an ommission in the previous version.
Good. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;