Boost logo

Boost Users :

From: Nic (n.morales.0_at_[hidden])
Date: 2024-05-03 19:48:46


Hi,
Hopefully this is the right place for this. This with Boost 1.81.0 It looks
like boost::adjacency_list's in_edge_iterator, out_edge_iterator, and for
bidirectional graphs also edge_iterator all are only input iterators.

This seems a bit restrictive, and is regardless of the type of EdgeList
template parameter. For example, this code (which seems a relatively
reasonable thing to want to do) doesn't work:
https://godbolt.org/z/n3PdEYo49

It doesn't work because transform_view doesn't define iterator_category if
the iterator is not at least a forward iterator (I'm a bit confused as to
why that is, but that's not a boost-related thing).

I did some digging and found out why the iterator is always an input
iterator:

The iterators are defined as following:

template < class BaseIter, class VertexDescriptor, class EdgeDescriptor,
        class Difference >
    struct in_edge_iter
    : iterator_adaptor< in_edge_iter< BaseIter, VertexDescriptor,
                            EdgeDescriptor, Difference >,
          BaseIter, EdgeDescriptor, use_default, EdgeDescriptor, Difference
>
    {
      // ....
    };

EdgeDescriptor is passed in as the reference type, but it is not a
reference so the iterator adaptor always chooses input_iterator_tag for the
iterator_category.

Does anyone know of a workaround, or know if this is the desired behavior
for edge iterators? Am I missing something obvious here?

Thank you very much,
Nicolas Morales



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net