cout << std::is_assignable<int*, std::nullptr_t>::value << endl;
cout << std::is_assignable<int*&, std::nullptr_t>::value << endl;
Output: 0 1
I do not understand why the first check returns false
I can assign a nullptr reference to a pointer, but I can not assign it to a raw pointer?
This is the opposite!
int* p = nullptr;
int*& pref = nullptr;
The second task, as expected, indicates an error:
error: cannot bind non-const lvalue reference of type int * & to rvalue of type int *
Can someone explain to me what is going on?
source
share