
From: John Nagle <nagle@animats.com>
Since space for a trailing null is required, the minimum "capacity" is currently 1.
This means your class supports strings that can never contain any data. Is that something that should be permissible?
The maximum value for "size()" is then "capacity()-1". That seems a little wierd. Should the trailing null be counted in "capacity?"
No, capacity() should return the maximum value size() can attain. Think about the typical approach to allocating a C string: size_t const MAX_LENGTH(10); char buffer[MAX_LENGTH + 1]; This permits using MAX_LENGTH in comparisons with strlen(buffer). I think capacity() is analogous to MAX_LENGTH. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;