|
Boost Users : |
Subject: Re: [Boost-users] [Range.Ex / String.Algo] Ambiguous call to overload function "find"
From: S.C. Leung (shaochiliang_at_[hidden])
Date: 2009-07-05 22:56:54
That's too strange. Maybe the test environments between us are different so
I want to send you the range_ex.zip I use. By the way, the "find_first"
really call the "find" by making a "Finder object" and that's where the
resolution failed. I'm also not sure
if the compiler options have side effects so I post my options as below:
/Od /D "_MBCS" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3
/nologo /c /ZI /TP /errorReport:prompt
Lastly, have you replaced std::string with const std::string? That will
cause the "find" within "find_first" resoluted as the "find" in
range/algorithm/find.hpp in my test environment.
Thank you for your work!
S.C. Leung
2009/7/5 Neil Groves <neil_at_[hidden]>
> 2009/7/3 S.C. Leung <shaochiliang_at_[hidden]>
>
>> Hi!
>> I have downloaded Range.Ex uploaded at 26.04.2009 09:09. It seems the
>> difficulties are still there.
>>
>
> The exact program you posted compiles without errors or warnings on Visual
> C++ 9. I installed Boost 1.39 and then copied over the RangeEx files.
>
> [...]
>
>> 009/7/3 Neil Groves <neil_at_[hidden]>
>>
>>> Hello!
>>>
>>> On Fri, Jul 3, 2009 at 2:38 AM, ÁºÉÜ³Ø <shaochiliang_at_[hidden]> wrote:
>>>
>>>> I use vc 9.0 to compile the following code with boost 1.39.0 and
>>>> range_ex.
>>>> #include<string>
>>>> #include<boost/algorithm/string.hpp>
>>>> #include<boost/range/algorithm.hpp>
>>>>
>>>> int main() {
>>>> std::string s = "hello";
>>>> boost::find_first(s, "lo");
>>>> return 0;
>>>> }
>>>>
>>> The compiler will complain ambiguous call to overload function "find".
>>>> I found there's also a "find" in boost/range/algorithm.hpp. Even worse when
>>>> I change the type of "s" to const std::string, the compiler will resolute
>>>> "find" call as the one in boost/range/algorithm.hpp
>>>> and reports an error "const_iterator is not a member of
>>>> std::_String_const_iterator". Now I just indicated the "find" call in
>>>> boost::find_first explicitly. Is there a better way to solve it?
>>>>
>>>
>
> This code compiles cleanly for me. I noticed that you are talking about
> "find" rather than "find_first" so I took the liberty of replacing the
> "find_first" with "find". This indeed produced a compiler error similar to
> the one you describe. However boost::find(s, "lo") does not match the
> boost/algorithm/string.hpp version because the second parameter should be a
> "Finder object used for searching". Please see:
>
> http://www.boost.org/doc/libs/1_39_0/doc/html/string_algo/reference.html#header.boost.algorithm.string.find_hpp
>
> It also does not match the RangeEx version because "find" is used to find
> an element, as opposed to a sub-sequence, from a range. Therefore I conclude
> that either, I have guessed the code snippet that causes the problem
> inaccurately, or that the code that produced the compiler error was simply
> incorrect.
>
> If I have guessed the code wrongly, would you please supply the exact code
> that reproduces the problem. I suspect that find_first is exactly the right
> solution. Please let me know either way.
>
> [...]
>
> Regards,
> Neil Groves
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net