Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #83574
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Bo Persson <bo@bo-persson.se> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: ambiguous reference to 'find' in std and std::ranges namespaces |
| Date | Wed, 13 Apr 2022 14:21:44 +0200 |
| Lines | 47 |
| Message-ID | <jbntipF5or8U1@mid.individual.net> (permalink) |
| References | <t35vs1$8pu$1@dont-email.me> <t36c3i$dpq$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net 83q97OHJkHq4GSXIoGw8PwVYXEUVrb5O4bbDSglt7J9nQ25OXO |
| Cancel-Lock | sha1:WWHBlI8K/WXFNkMlrP2xaednE1A= |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 |
| Content-Language | sv |
| In-Reply-To | <t36c3i$dpq$1@dont-email.me> |
| Xref | csiph.com comp.lang.c++:83574 |
Show key headers only | View raw
On 2022-04-13 at 13:27, Paavo Helde wrote:
> 13.04.2022 10:58 Ralf Goertz kirjutas:
>> Hi,
>>
>> why do I get the error (with gcc-Version 11.2.1):
>>
>>
>> find_test.cc: In function ‘int main()’:
>> find_test.cc:10:41: error: reference to ‘find’ is ambiguous
>> 10 | std::vector<int>::const_iterator it=find(v,47);
>> | ^~~~
>>
>> when compiling the following code:
>>
>> #include <algorithm>
>> #include <ranges>
>> #include <vector>
>>
>> using namespace std; // *
>> using namespace std::ranges; // **
>>
>> int main() {
>> const std::vector<int> v({47,11});
>> std::vector<int>::const_iterator it=find(v,47);
>> }
>
> Most probably this is because std::ranges::find is not a function
> template, but something called "niebloid", to disable ADL
> ("https://en.cppreference.com/w/cpp/algorithm/ranges/find").
>
> In my implementation it appears to be implemented as a function object,
> having operator() member functions. I guess the problem is caused by
> this specific implementation, as the whole point of niebloids seems to
> be the opposite (avoiding clashes with the std:: namespace).
That works from *inside* the ranges namespace. Once an object is found,
the compiler knows not to do ADL, because that's only for functions.
>
>> AFAICT there is no way that std::find could be a candidate whereas
>> std::ranges::find matches.
>
> I guess the compiler never gets so far as to consider template overload
> candidates.
It cannot do that when the candidates are not all functions. There are
no overload rules for objects (like niebloids).
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ambiguous reference to 'find' in std and std::ranges namespaces Ralf Goertz <me@myprovider.invalid> - 2022-04-13 09:58 +0200
Re: ambiguous reference to 'find' in std and std::ranges namespaces Paavo Helde <eesnimi@osa.pri.ee> - 2022-04-13 14:27 +0300
Re: ambiguous reference to 'find' in std and std::ranges namespaces Bo Persson <bo@bo-persson.se> - 2022-04-13 14:21 +0200
Re: ambiguous reference to 'find' in std and std::ranges namespaces Paavo Helde <eesnimi@osa.pri.ee> - 2022-04-13 15:31 +0300
Re: ambiguous reference to 'find' in std and std::ranges namespaces Juha Nieminen <nospam@thanks.invalid> - 2022-04-13 13:26 +0000
Re: ambiguous reference to 'find' in std and std::ranges namespaces Juha Nieminen <nospam@thanks.invalid> - 2022-04-13 13:28 +0000
Re: ambiguous reference to 'find' in std and std::ranges namespaces Paavo Helde <eesnimi@osa.pri.ee> - 2022-04-13 17:26 +0300
Re: ambiguous reference to 'find' in std and std::ranges namespaces Christian Gollwitzer <auriocus@gmx.de> - 2022-04-14 07:13 +0200
Re: ambiguous reference to 'find' in std and std::ranges namespaces Ralf Goertz <me@myprovider.invalid> - 2022-04-14 08:57 +0200
Re: ambiguous reference to 'find' in std and std::ranges namespaces Bo Persson <bo@bo-persson.se> - 2022-04-14 13:23 +0200
Re: ambiguous reference to 'find' in std and std::ranges namespaces Paavo Helde <eesnimi@osa.pri.ee> - 2022-04-14 16:32 +0300
Re: ambiguous reference to 'find' in std and std::ranges namespaces Bo Persson <bo@bo-persson.se> - 2022-04-14 18:30 +0200
Re: ambiguous reference to 'find' in std and std::ranges namespaces Ralf Goertz <me@myprovider.invalid> - 2022-04-15 10:14 +0200
Re: ambiguous reference to 'find' in std and std::ranges namespaces Manfred <noname@add.invalid> - 2022-04-14 15:02 +0200
Re: ambiguous reference to 'find' in std and std::ranges namespaces Christian Hanné <the.hanne@gmail.com> - 2022-04-15 14:39 +0200
csiph-web