From: Dean M. B. <mik...@gm...> - 2010-10-22 05:51:00
|
On Fri, Oct 22, 2010 at 3:17 AM, Kim Gräsman <kim...@gm...> wrote: > Hi Dean, > > On Thu, Oct 21, 2010 at 06:34, Dean Michael Berris > <mik...@gm...> wrote: >> >>> So, I think there's merit to not expecting COW from std::string. >>> >> >> Yup, but I haven't been writing cpp-netlib to expect COW. I just think >> that removing copies can be done later on. ;) > > Right, I just wanted to make sure you were aware of the reputation of > std::string with COW. It's not great ;-) > Yeah, I've been bitten by those bugs too. :D > That said, maybe it's not such a bad idea. Multiple threads make it > harder to get right, but perhaps not intrinsically worse than heap > allocation + copy. I'll have to mull on that for a while. > Yup, it's no worse than an allocation + copy. You can't do the allocation and copy atomically either, which means the overhead of locking and things like that may be higher than the cost of COW. Someday when my development machine, time, and other things permit, I might work on an immutable string class -- similar to what the D programming language has -- as a replacement to std::string. Although std::string is the standard, I don't mind writing a better string class at some point that "does the right thing". Alas, I'm dealing with the SNAFU that is upgrading Ubuntu 10.04 to 10.10. nvidia+xorg-1.9 do not play nice yet. :( -- Dean Michael Berris deanberris.com |