From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-06-03 08:38:53
>I have tested the sandbox version of the static sized strings. It works
>but there are a few inconveniences that I want to point out.
I have been writing a series of test cases (boost-sandbox/libs/test) and
fixing several bugs. Have you tried these? Also, what compiler(s) are you
>1. The abstract base class.
>Having an ABC to handle fixed strings of various lengths is a good idea but
>is not very practical. I understand that the main purpose is to allow fixed
>strings to be passed to functions without using templates.
>int countwords(const boost::char_string & str);
>unfortunatly the ABC makes it difficult to pass anything but fixed strings.
>you want to pass a string literal, a character array or a std::string you
>create a temporary fixed_string<>.
>countwords(boost::fixed_string<20>("The quick brown fox"));
This is an unfortunate side-affect of using the ABC technique that affects
John's implementation as well. Your proposed solution looks interesting, but
I don't know how practical it will be for the string manipulation operations
(w.r.t. buffer safety).
Rob proposed a "make_string" function, which would simplify this a little.
>One of the applications I can see for fixed_string is when you want to
>dynamic allocation but still want to use the std::string interface and
>algorithms. In that perspective it seems strange that substr returns a
>std::string instead of a fixed_string.
This is related to the above problem. You cannot create an instance of
boost::char_string, etc. and as such cannot implement substr in the usual
way (this is the proplem I was having with operator+). The solution would be
to defione an alternate substr function in fixed_string, but this would not
solve the problem for boost::char_string, etc.
The alternative would be to use a ranged string (pointer to the fixed_string
buffer and length), but the problem with this is null-termination.
I do not see an easy way around this without removing the ABC design, since
it is not possible to do fixed_string< length() > or something similar.
>Still missing a method to update the length to reflect the current string
>length. I think a resize without arguments would be a good solution.
I'll add this soon. I have mainly been focusing on getting documentation and
the test cases up.
>I don't have the standard basic_string interface available but I am pretty
>sure that operator doesn't throw an exception if the argument is outside
This is a deviation from the standard. If i > capacity() then the index will
be out of the string buffer range and a buffer overrun can occur. This
generates an exception to prevent the overrun.
I should add this to the docs.
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo