Boost logo

Boost Users :

Subject: Re: [Boost-users] automatic conversion between boost::container::string and std::string
From: Yi Ding (yi.s.ding_at_[hidden])
Date: 2011-11-18 12:44:09


On 11/17/2011 3:29 PM, Ion Gaztañaga wrote:
> El 17/11/2011 18:31, Yi Ding escribió:
>> Hi,
>>
>> Thanks for the new containers library. There's a lot of useful stuff
>> in there. I was wondering: is it possible to do automatic conversion
>> between boost::container::string and std::string? A lot of libraries
>> currently use std::string.
>>
>> Thanks,
>> Yi
>
> Automatic conversion is not usually a good idea. I guess you can use
> std::string(boost_string.c_str());
>
> Maybe we could do an ugly hack to move memory allocated with
> std::string to boost::container::string, avoiding costly copies, but
> that of course, would require playing with underfined behaviour.

That makes sense. It does make it difficult to move an existing
codebase over to boost strings. If I want to write interfaces that
handle both std string and boost strings, what's the preferred way to do
that? boost range?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net