From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-05-10 07:46:43
John Nagle wrote:
>John Nagle wrote:
>> I've been doing some work on this too. I made char_string
>>a subclass of a non-templated char_string_base, so you can
>>pass references to char_string_base. This has the disadvantage
>>of requiring a vtable, but makes the class much more useful.
>> I'll put this someplace publicly visible in the next day
> It's at
>Take a look and see if you like the direction this is going.
Hmm. Which way to go? My latest version has been generalized to incorporate
char/wchar_t support, so you can use wide-character strings. It also uses a
StringPolicy class (i.e. char_traits) so you can control the length, copy,
comparison, etc functions that are used.
BTW: the reason I use the const char( & s )[ m ] on compilers that support
it is because this picks up the string literals in order to remove a call to
strlen, thus improving performance.
Which design do you like better: using a virtual base class, or using a
policy template? I have been working on providing an interface similar to
std::basic_string, hence some of my latest design choices.
Ideally, the class should:
* safeguard against buffer overflow on static-sized character arrays;
* interoperate with classic C string operations;
* interoperate with std::basic_string;
* provide support for null-terminated strings and also fixed-length
* prevent silly mistakes by the user, ideally providing compile-time errors
At the moment, both implementations provide a different subset of those
aims. Do you mind if I look into this and let you know what I come up with.
Use MSN Messenger to send music and pics to your friends
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk