
Since space for a trailing null is required, the minimum "capacity" is currently 1. The maximum value for "size()" is then "capacity()-1". That seems a little wierd. Should the trailing null be counted in "capacity?" John Nagle Animats Rob Stewart wrote:
From: "Reece Dunn" <msclrhd@hotmail.com>
Rob Stewart wrote:
From: "Reece Dunn" <msclrhd@hotmail.com>
Rob Stewart wrote:
* Should fixed_string support zero-length strings?
You can have zero-length strings in my implementation (this is what fized_string() defaults to). What you *can't* have is a zero-*capacity* string, which is the same as CharT[ 0 ].
I did mean zero-capacity. I didn't look at your implementation at this point, but I did notice that John's class declares a size N array, so for N == 0, his would fail to compile. Is the same true of yours?
yup. With mine, you'll also get an additional error, e.g.: fixed_string.hpp(101) : error C2039: 'value' : is not a member of 'boost::fixed_string<n>::zero_buffer_error'
Is there any reason you'd want a zero-capacity buffer?
My only thought was generic code that might be called upon to use a zero-capacity string. Such a string wouldn't be of much use, of course, so it is probably best to disallow it. I just wasn't sure whether yours would disallow it.