Opened 11 years ago

Last modified 7 years ago

#1887 new Bugs

[doc] input_iterator_archetype is not a valid InputIterator

Reported by: Eric Niebler Owned by: Dave Abrahams
Milestone: Boost 1.36.0 Component: concept_check
Version: Boost 1.35.0 Severity: Problem
Keywords: Cc:


creating_concepts.htm shows an InputIterator? concept which requires that the type of *it++ is the same as the value_type. (This is legit according to the C++03 requirements table for input iterators, but probably too strict in practice.) Then, concept_covering.htm shows an input_iterator_archetype, which fails to meet this requirement because *it++ will return an object of type input_iterator_archetype::reference which is distinct from, but convertible to, the iterator's value_type. If you try to assert that input_iterator_archetype satisfies the InputIterator? concepts as both are presented in the docs, it will fail.

This is only a documentation problem. As defined by the BCCL, input_iterator_archetype is a valid InputIterator?.

Attachments (1)

creating_concepts.patch (3.6 KB) - added by Eric Niebler 7 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 11 years ago by Dave Abrahams

Status: newassigned

comment:2 Changed 9 years ago by Dave Abrahams

There may be a problem, but it's not quite what you said. Table 72 quite clearly says that the type of *r++ is T, the iterator's value_type.

comment:3 Changed 9 years ago by Dave Abrahams

Owner: changed from Dave Abrahams to Eric Niebler
Status: assignednew

Well, there's probably a bug in the C++03 standard here. What it actually says, if you read carefully enough, is that *a is required to be convertible to T—where a is any value of type X, the iterator type)—but *r++ is required to be exactly T, where r is of type X&. I'm guessing the strictly correct thing to do in the archetype is something like this:

   T operator*();
   reference operator*() const;

Your thoughts?

Changed 7 years ago by Eric Niebler

Attachment: creating_concepts.patch added

comment:4 Changed 7 years ago by Eric Niebler

Owner: changed from Eric Niebler to Dave Abrahams

The bug in the standard has been fixed in C++11. Both *a and *i++ are merely required to convert something convertible to T. So the input_iterator_archetype is correct, and only the docs are wrong. I've attached a patch.

Note: See TracTickets for help on using tickets.