thanks for the idea. I think the c++ std lib at least in gcc needs fixing though. it's only find and compare that it conflicts with. or so I thought.
interesting. I did not want to mangle my own libraries because of someone else's bug.
the error message certainly doesn't fit the problem, does it?
is there some way to use a macro to do this so I can take out the workaround at the top of the code?
This is ambiguous, and the error diagnostic points out the ambiguity:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <string>
#include <algorithm>
namespace my
{
template < typename I, typename T > void find( I, I, T ) ;
void foo( std::string str )
{
// ambiguous:
// normal unqualified look up finds my::find
// argument-dependent lookup finds std::find
// http://en.cppreference.com/w/cpp/language/adl
find( str.begin(), str.end(), 89 ) ;
}
}
main.cpp: In function 'void my::foo(std::__cxx11::string)':
main.cpp:14:42: error: call of overloaded 'find(...)' is ambiguous
find( str.begin(), str.end(), 89 ) ;
^
main.cpp:6:46: note: candidate: void my::find(I, I, T) [with I = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; T = int]
template < typename I, typename T > void find( I, I, T ) ;
^~~~
In file included from /usr/local/include/c++/6.1.0/algorithm:62:0,
from main.cpp:2:
/usr/local/include/c++/6.1.0/bits/stl_algo.h:3791:5: note: candidate: _IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; _Tp = int]
find(_InputIterator __first, _InputIterator __last,
^~~~