Hi!
Hi all,
given this code...
#include <deque>
#include <boost/algorithm/string/find.hpp>
#include <boost/operators.hpp>
template< class Rng, class T >
typename boost::range_iterator<Rng>::type find( Rng& rng, T const& t ) {
return std::find( boost::begin(rng), boost::end(rng), t );
}
struct STest : boost::equality_comparable<STest>
{
bool operator==(STest const& test) const { return true; }
};
void main() {
std::deque<STest> deq;
find( deq, STest() );
}
...the VS9 compiler fails with “error C2668: 'find' : ambiguous call to overloaded function”. This is due to the fact that STest inherits from a type that is defined in boost namespace which triggers the compiler to try ADL which finds boost::algorithm::find(RangeT& Input, const FinderT& Finder).
An obvious solution is to prefix the call to find(…) with ::, but this feels wrong: It does not make sense that the compiler does ADL in this case. There is nothing special about boost::equality_comparable<…> that would make it a more natural argument for boost::algorithm::find(RangeT& Input, const FinderT& Finder) than any other type, and there is nothing special about boost::algorithm::find(RangeT& Input, const FinderT& Finder) that would make it a more natural find implementation for boost::equality_comparable<…> than my find(Rng& rng, T const& t). Maybe the function and the type should not be in the same namespace in the first place. Currently, the mere presence of the specific implementation boost::algorithm::find(RangeT& Input, const FinderT& Finder) disallows the implementation of the canonical find(Rng& rng, T const& t).
Opinions? Suggestions?
Thanks a lot,
Volker
--
Volker Schöch (vschoech@think-cell.com)
Senior Software Engineer
think-cell Software GmbH http://www.think-cell.com Chausseestr. 8/E phone +49 30 666473-10 10115 Berlin, Germany toll-free (US) +1 800 891 8091 Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl Amtsgericht Berlin-Charlottenburg, HRB 85229
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users