
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 or two.
It's at http://www.animats.com/source Take a look and see if you like the direction this is going. Thanks.
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 strings; * prevent silly mistakes by the user, ideally providing compile-time errors wherever possible. 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. Regards, Reece _________________________________________________________________ Use MSN Messenger to send music and pics to your friends http://www.msn.co.uk/messenger