Opened 12 years ago

Closed 12 years ago

#4642 closed Bugs (fixed)

Including some BGL header files and boost/range/irange.hpp causes compile errors due to the name conflict

Reported by: Naoki Yoshioka <yoshioka.naoki@…> Owned by: Andrew Sutton
Milestone: To Be Determined Component: graph
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc: Jeremiah Willcock, Neil Groves, Dave Abrahams, jsiek

Description

Some BGL headers like boost/graph/detail/adjacency_list.hpp include boost/pending/integer_range.hpp and use a class template boost::integer_range to represent a vertex/edge list. Since 1.44.0, however, Boost.Range supports a class template which has the same name and probably the same role in boost/range/irange.hpp; it didn't have integer_range and instead used boost::iterator_range<boost::range_detail::integer_iterator<Integer> > in 1.43.0. Therefore the following simple code causes compile errors using 1.44.0.

// test.cpp
#include <boost/graph/adjacency_list.hpp>
#include <boost/range/irange.hpp>

int main() { return 0; }

The errors are as follows;

$ g++ --version
g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ test.cpp -I/usr/local/include/boost_1_44_0
In file included from test.cpp:2:
/usr/local/include/boost_1_44_0/boost/range/irange.hpp:176: error: redefinition of ‘class boost::integer_range<IntegerType>’
/usr/local/include/boost_1_44_0/boost/pending/integer_range.hpp:23: error: previous definition of ‘class boost::integer_range<IntegerType>’
$ g++ test.cpp -I/usr/local/include/boost_1_43_0
$ 

Note that /usr/local/include/boost_1_xx_x is the directory the boost 1.xx.x is installed.

To fix this problem, I think it's OK just to replace the including file from boost/pending/integer_range.hpp to boost/range/irange.hpp in BGL. The header files which include boost/pending/integer_range.hpp are as follows;

  • boost/graph/adjacency_matrix.hpp
  • boost/graph/detail/adjacency_list.hpp
  • boost/graph/edge_list.hpp
  • boost/graph/vector_as_graph.hpp

Note that I haven't checked whether this modification works completely well or not. I've just checked the above example code works after this modification.

After this modification, I think boost/pending/integer_range.hpp can be removed from the boost library because no other files include this pending header file.

Attachments (1)

patchfile.patch (2.3 KB ) - added by Naoki Yoshioka <yoshioka.naoki@…> 12 years ago.
to replace the including file from pending one to that in Boost.Range

Download all attachments as: .zip

Change History (3)

by Naoki Yoshioka <yoshioka.naoki@…>, 12 years ago

Attachment: patchfile.patch added

to replace the including file from pending one to that in Boost.Range

comment:1 by Andrew Sutton, 12 years ago

Deprecated pending/integer_range (will be removed in a future release) and replaced all references in the BGL with range/irange.hpp. Changes in r65385.

comment:2 by Jeremiah Willcock, 12 years ago

Resolution: fixed
Status: newclosed

(In [67035]) Removed <boost/pending/integer_range.hpp> and a few more uses of it; fixes #4642

Note: See TracTickets for help on using tickets.