Il 26/05/2015 17:56, Victor Bazarov ha scritto:
> On 5/26/2015 11:26 AM, Luca Risolia wrote:
>> On 26/05/2015 13:47, Victor Bazarov wrote:
>>> Either way, if it's 'nullptr_t', it should pick foo(int*)
>>
>> std::nullptr_t is defined as decltype(nullptr). If NULL is of type
>> std::nullptr_t, then the first choice for foo(NULL) should be
>> foo(std::nullptr_t), while both foo(int*) and foo(int) should be a
>> second choice.
>
> What if there is no foo(std::nullptr_t)? Does conversion from nullptr_t
> to int* has the same rank as conversion from nullptr_t to int?
std::nullptr_t cannot be converted to int, but can be implicitly
converted to int* (and to any raw pointer types). So I was imprecise in
the second part of my statement: foo(int) is not an option at all if
NULL is of type std::nullptr_t. To answer your question then, if there's
no foo(std::nullptr_t), then the only valid option would be foo(int*).
Ergo in some C++11 implementations (like mine), which complain about
ambiguities in the foo(NULL) call, NULL is not of type std::nullptr_t.