Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-06-21 07:46:35


John Nagle wrote:
>Reece Dunn wrote:
>>John Nagle wrote:
>>The problems arise in the interation with basic_string_impl and how to
>>implement swap and functions that require constructing a string object.
>Why do you need to construct a string object to swap?
>Just swap one character at a time.

There were 3 things I was cxonsidering when moving to the non-virtual
implementation:

[1] How do I pass the buffer and capacity to the implementation while
allowing both fixed_string_base and fixed_string access to the basic_string
interface? I have chosen to route the data through one of the basic_string
constructors, requiring a const_cast. This is the best approach AFAICS.

[2] How do I implement the swap function? The solution I arrived at is the
one you suggest: to swap the data character-by-character. What you have to
consider when doing this is that the strings don't exceed capacity,
resulting in additional logic.

[3] How do I approach the substr function and the + operators? Although it
is now possible to construct a fixed_string_base object from a fixed_string
object, you will run into problems when constructing from a temporary
(because the fixed_string temporary will have been destroyed, invalidating
the buffer).

Given this, the implementation of these functions are still in fixed_string
and thus not accessible to [w]char_string.

I have replaced the old implementation with this one in the sandbox if you
want to take a look. Also, feel free to adapt it to your version if you
want.

Regards,
Reece

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger


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