Opened 10 years ago

Closed 10 years ago

#7035 closed Feature Requests (wontfix)

pair<iterator, iterator>, tie, and Boost.Range co-operate poorly

Reported by: philipp.moeller@… Owned by: Jeremiah Willcock
Milestone: To Be Determined Component: graph
Version: Boost 1.49.0 Severity: Problem
Keywords: Cc:

Description

Boost.Graph returns std::pair<iterator, iterator> for all ranges. This works nicely with the common:

  iterator begin, end;
  for(tie(begin, end) = vertices(graph); begin != end; ++begin) {}

or Boost.Range algorithms.

When adapting new graphs it is often more convenient to return an iterator_range and work with it, but this doesn't support the tie' idiom anymore and breaks a lot of code in Boost.Graph.

Unifying this would be a nice-to-have feature.

I see two options for this: Either at support for tie to Range or transition Graph towards Range algorithms. The first seems much easier to do, but is also a less clean solution because it somewhat muddies Range conceptually.

On the other hand it is not clear to me how much Range is going to change with standardization and what version, if any, will end up in the next standard.

Change History (1)

comment:1 by Jeremiah Willcock, 10 years ago

Resolution: wontfix
Status: newclosed

This is a good idea (returning std::pair breaks C++11 range-based for as well), but there are lots of places that assume the return type is exactly a pair of two iterators, so I'm closing this as wontfix for compatibility reasons. If we do any kind of updates to the interface, though, this change should be made.

Note: See TracTickets for help on using tickets.