Boost logo

Boost :

From: John Nagle (nagle_at_[hidden])
Date: 2004-05-07 19:23:18


    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.

    A fundamental question is whether we assume strings are
null-terminated, like C strings, or carry along an in-use
length, like STL strings. There are arguments for both
forms. It's possible to provide all the reasonable
STL string operations and the C string operations,
and make them compatible, either way. Performance
differs, though. If strings are null-terminated,
then STL operations like

        char_string s;
        s += 'a';

are very slow. If strings are counted, then
C string operations like

        s[20] = 'a';

must update the length. Which way to go?

    This is a good direction.. It's one of those simple
things that just ought to be there.

                                John Nagle
                                Team Overbot

Reece Dunn wrote:
> John Nagle wrote:
>
>> Reece Dunn wrote:
>>
>>> John Nagle wrote:
>>>
>>>> Reece Dunn wrote:
>>>>
>>>>> There is currently a static-sized array in the Boost library that
>>>>> allows you to operate on arrays of fixed size. I was wondering if
>>>>> something similar exists for strings, in particular, providing
>>>>> buffer-overflow safe string operations.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk