Opened 14 years ago

Last modified 11 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:

Description

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 11 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Dave Abrahams, 14 years ago

Status: newassigned

comment:2 by Dave Abrahams, 13 years ago

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 by Dave Abrahams, 13 years ago

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?

by Eric Niebler, 11 years ago

Attachment: creating_concepts.patch added

comment:4 by Eric Niebler, 11 years ago

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.