Why is unique_ptr operator-> not const-overloaded?
std::unique_ptr::operator-> has the signature pointer operator->() const noexcept; So operator-> is const but returns a mutable pointer. This allows for code like: void myConstMemberFunction() const { myUniquePtrMember->nonConstFunction(); } Why does the standard allow this, and what is the best way to prevent usage as presented above? Think about it like a normal pointer: int * const i; is a const pointer to a non- const int . You can change the int , but not the pointer. int const * i; is a non- const pointer to a const int . You can change the pointer but not the int . Now, for unique_ptr ,