
On Thu, Jan 27, 2011 at 10:48 PM, Chad Nelson <chad.thecomfychair@gmail.com> wrote:
On Thu, 27 Jan 2011 22:16:14 +0800 Dean Michael Berris <mikhailberis@gmail.com> wrote:
Question: if you replaced std::string with your immutable string, how would you build strings one character at a time for it?
[...] Actually, what std::copy requires is an iterator to model the OutputIterator concept. This means, std::back_inserter would somehow be analogous to std::ostream_iterator<>, and while we're at it, you build strings with a "stream" instead of modifying an already created string. :)
In other words, essentially the same as using a mutable buffer, then copying the data to an immutable string. I'll be interested in the code you propose for it.
Actually, it won't be a copy. :) If the mutable buffer was a sequence of reference-counted fixed-sized blocks, then you can imagine building an istring that just referred to these reference-counted fixed-sized blocks. The other way is to just move the ownership of the blocks to the built istring. Your "stream" interface would pretty much use the same interface that the output stream operations and underneath can benefit from discontiguous chunks of memory used as buffers.
So why would I not want to call it boost::string? ;)
Because it isn't a string, in the accepted C++ sense? :-)
Well one thing is certain: I suck at names. So if there's a suitable name that better models my notion of a string, then I'm open to suggestions. [...]
The "istring" you mentioned in a later message is good enough for this discussion, though it might not be descriptive enough for a final name.
I agree. Help wanted on a better name for the immutable string. :) -- Dean Michael Berris about.me/deanberris