|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-07-21 11:34:02
Gunter Winkler <guwi17_at_[hidden]> writes:
> Hello,
>
> I tried to use boost::zip_iterator to sort 2 parallel arrays. Unfortunatly gcc
> does not compile the appended example because it can not convert
>
> boost::detail::iterator_category_with_traversal<std::input_iterator_tag,
> boost::random_access_traversal_tag>
>
> to either
> std::bidirectional_iterator_tag
> or
> std::random_access_iterator_tag.
> Thus it cannot dispatch the correct stl::__copy_backward() procedure.
>
> Is sort() not yet supported?
Here's the thing: std::bidirectional_iterator_tag and
std::random_access_iterator_tag both would imply that the iterator
statisfied the Forward Iterator Requirements. Forward Iterator
Requirements say that *a must be T&. zip_iterator returns a tuple of
references, not a reference itself, from its operator*. Therefore,
you can't legally call it a Forward Iterator, and using either
std::bidirectional_iterator_tag or std::random_access_iterator_tag
would be lying.
Now, _does_ sort actually need a Forward Iterator in order to do its
work? It's not clear that it does, but the original iterator
requirements didn't account for beasts like zip_iterator. It's a bad
situation, and it's made worse because I don't know how to write a
specification for sort() that would allow a zip_iterator to work.
How would you describe the result?
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk