Opened 8 years ago

Closed 6 years ago

#4051 closed Bugs (fixed)

[range][string_algo] Conflict between algorithm names

Reported by: Jeremiah Willcock Owned by: Marshall Clow
Milestone: Boost 1.43.0 Component: algorithm
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:


When I try to include both Boost.Range algorithms (in the current trunk version) and Boost.Algorithm, using a file such as the following:

#include <boost/algorithm/string.hpp>
#include <boost/range/algorithm.hpp>

I receive several errors about duplicate definitions. I am using gcc 4.1.2 on Linux.

./boost/range/algorithm/find.hpp:28: error: ‘template<class SinglePassRange, class Value> typename boost::range_iterator::type boost::find(SinglePassRange&, const Value&)’ conflicts with previous using declaration ‘template<class RangeT, class FinderT> boost::iterator_range<typename boost::range_iterator<C>::type> boost::algorithm::find(RangeT&, const FinderT&)’
./boost/range/algorithm/lexicographical_compare.hpp:28: error: ‘template<class SinglePassRange1, class SinglePassRange2> bool boost::lexicographical_compare(const SinglePassRange1&, const SinglePassRange2&)’ conflicts with previous using declaration ‘template<class Range1T, class Range2T> bool boost::algorithm::lexicographical_compare(const Range1T&, const Range2T&)’
./boost/range/algorithm/lexicographical_compare.hpp:42: error: ‘template<class SinglePassRange1, class SinglePassRange2, class BinaryPredicate> bool boost::lexicographical_compare(const SinglePassRange1&, const SinglePassRange2&, BinaryPredicate)’ conflicts with previous using declaration ‘template<class Range1T, class Range2T, class PredicateT> bool boost::algorithm::lexicographical_compare(const Range1T&, const Range2T&, PredicateT)’

The using declarations mentioned in the error message are in files such as boost/algorithm/string/find.hpp.

Attachments (0)

Change History (4)

comment:1 Changed 8 years ago by Jeremiah Willcock

Component: rangestring_algo
Owner: changed from Thorsten Ottosen to Pavol Droba

comment:2 Changed 8 years ago by Neil Groves

I have altered Boost.Range to implement the range algorithms in the namespace boost::range. These are then brought into the boost namespace with a using statement. For some algorithms this should mean that the overloads can be resolved, but in the cases that the functions are ambiguous the user can easily add algorithm:: or range:: to disambiguate.

comment:3 Changed 6 years ago by Marshall Clow

Component: string_algoalgorithm
Owner: changed from Pavol Droba to Marshall Clow

comment:4 Changed 6 years ago by Marshall Clow

Resolution: fixed
Status: newclosed

Just tried this with the latest release branch (coming up to 1.49), and I don't get any errors:

#include <boost/algorithm/string.hpp>
#include <boost/range/algorithm.hpp>

int main (int argc, const char * argv[]) {
	return 0;

Closing this ticket. If you have more information/problems, please re-open.

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Marshall Clow.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.