Boost logo

Boost :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2006-10-12 15:49:48


"Jeff Garland" <jeff_at_[hidden]> wrote

> Caleb Epstein wrote:
>> On 10/12/06, Arkadiy Vertleyb <vertleyb_at_[hidden]> wrote:
>>> "Jeff Garland" <jeff_at_[hidden]> wrote
>>
>>>> So a core goal of the library is that you can
>>>> use super_string in some code and then seamlessly pass that instance to
>>>> existing interfaces written in terms of std::string for zero cost.
>>> Not exactly... the cost would be runtime -- to allocate a copy of the
>>> string. You wouldn't be able to pass anything other than "std::string"
>>> to
>>> "const std::string&" without copying it first, would you?
>>
>> Anything derived from std::basic_string<char> would work too. Super
>> String is:
>>
>> template<class char_type >
>> class basic_super_string : public std::basic_string<char_type>
>>
>> So there would be no copies.
>
> Exactly right.

I didn't realise that it's derived from the standard string, sorry.

However, this will bring other problems. First, traits designed for
std::string will not work for this new class. More importantly, according
to the standard, the basic_string class destructor is not virtual, and so
basic_string is not intended for derivation. As far as I can remember,
deriving from a standard container has always been considered a bad
practice...

Regards,
Arkadiy


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