Boost logo

Boost :

Subject: Re: [boost] [string] proposal
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2011-01-26 12:05:29


On 26.01.2011, at 17:06, Dean Michael Berris wrote:

> In one of the previous messages I laid out an algorithm template like so:
>
> template <class String>
> void foo(String s) {
> view<encoding> encoded(s);
> // deal with encoded from here on out
> }

I don't see how such an algorithm implementation is technically feasible. If the type substituted for String doesn't intrinsically know what its encoding is, how would view<encoding> know how to present the data in the requested encoding? How would it know how to transcode?

For that matter, why would foo's implementer care at all about the encoding? I cannot really think of any algorithms (save transcoding algorithms themselves) that would care about the actual encoding. What they typically want is the sequence of code points or more likely characters that the string represents. But if the string doesn't know what encoding its internal data is in, the algorithm cannot get the code points without someone telling it what the encoding is. By making the string oblivious of the data's actual encoding, you put the burden of that on the user of the string class, who now has to supply every single algorithm that wants to do something with the string beyond looking at its raw data with the actual encoding of the string.

Unless I completely misunderstand what you want, of course.

Sebastian


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