c++ - Why is nullptr_t not assignable to int*?

Viewed 550
cout << std::is_assignable<int*, std::nullptr_t>::value << endl;
cout << std::is_assignable<int*&, std::nullptr_t>::value << endl;

The output is: 0 1

I don't understand why the first check returns false

I can assign nullptr to a reference to pointer, but I cannot assign it to a raw pointer?

It's the inverse!

int* p = nullptr;
int*& pref = nullptr;

The second assignment, as expected, flags an error:

error: cannot bind non-const lvalue reference of type int*& to an rvalue of type int*

Can someone explain me what is going on?

1 Answers
Related