Boost logo

Boost :

From: bwood (coal_at_[hidden])
Date: 2008-01-12 20:14:30


This is a MIME encoded message.

--=_ccfcf18dd64bcfe340962a34fcd9d26a
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Thorsten Ottosen wrote:
>brass goowy skrev:
>> utility_class.html says, "Recall that many default
>> constructed iterators are singular..."
>>
>> I didn't find other uses of the word singular in the
>> documentation and am not sure what you mean. Are you
>> saying they are not meant to be range endpoints?
>
> From the standard 24.1:
>
>"Iterators can also have singular values that are
>not associated with any container. [ Example: After the declaration of
>an uninitialized pointer x (as with int* x;), x
>must always be assumed to have a singular value of a pointer. ?end
>example ] Results of most expressions are undefined
>for singular values; the only exceptions are destroying an iterator
that
>holds a singular value and the assignment of a
>non-singular value to an iterator that holds a singular value. In this
>case the singular value is overwritten the same way
>as any other value. Dereferenceable values are always non-singular."
>

OK, thanks.

>> I think the "sub" in the class name sub_range is kind of
>> misleading. The documentation has the following:
>> "Imagine that we have an algorithm that searches for a
>> sub-string in a string. The result is an iterator_range,
>> that delimits the match. We need to store the result from
>> this algorithm. Here is an example of how we can do it with
>> and without sub_range
>>
>> std::string str("hello");
>> iterator_range<std::string::iterator> ir = find_first( str, "ll" );
>> sub_range<std::string> sub = find_first( str, "ll"
);"
>>
>> The docs also say, "The iterator_range class is templated on an
>> Forward Traversal Iterator and should be used whenever fairly
>> general code is needed. The sub_range class is templated on an
>> Forward Range and it is less general, but a bit easier to use
>> since its template argument is easier to specify. The biggest
>> difference is, however, that a sub_range can propagate
>> constness because it knows what a corresponding const_iterator is."
>>
>> The sample code that has a sub-string with either an
>> iterator_range or sub_range and the description of the
>> two classes don't give much basis for sub being in the
>> name.
>
>So you would just call it range? Possible, but difficult to do now.
>

I prefer range to sub_range. It isn't that important to
me, but I suggest you make some comment in the documentation
about the matter. That might lead to some further ideas.

>> I didn't find anything about serialization in the docs.
>> iterator_range has an operator<<, but understandably no
>> operator>>. Do you plan to add something in this area?
>
>No. Don't Boost.Serialization have support for serializing a
[begin,end)
>range?

Not to my knowledge. Even if B.Ser had that, I think using it
would require what you are encouraging people to get away from
with the Range library: passing around iterators.

Brian Wood
Ebenezer Enterprises
www.webebenezer.net
--=_ccfcf18dd64bcfe340962a34fcd9d26a--


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