Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-03-03 16:07:11


Peter Dimov wrote:
> Jonathan Turkanis wrote:
>
> [...]
>
>> For example, if I rewrite the following to use read instead of get
>>
>> template<typename Source>
>> character get(Source& src)
>> {
>> character c = io::get(src);
>> if (c.good() && c == comment_char_)
>> while (c.good() && c != '\n')
>> c = io::get(src);
>> return c;
>> }
>
> Yes, you are right. A "proper" in-place read-based filter that
> implements the above (minus the bug)

Care to share the bug with me? ;-) I know that the comment character is checked
twice, but this seems harmless.

> is much, much harder to write and
> understand. It will also be much, much faster,

Actually the distinction between an in-place filter and a filter which produces
a modified copy of its input is separate from the get/read question. I'm going
to provide optimized treament for in-place filters (this is one of the planned
changes that's been on hold), but not all filters can be represented that way.
It's especially useful for filters which only observe their input, such as line-
or character-counting filters, or filters which implement an offset view of the
downstream device.

> but the character
> version may be fast enough for most uses.

So all things considered, do you think the basic_character abstraction makes the
get() function and the InputFilter concept unreasonably complex?

Thanks for you comments!

Jonathan


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