I have the following code:
msg_buf_ptr = std::make_unique();
return QDataStream{msg_buf_ptr, QIODevice::WriteOnly};
I am
No, this is not a special case; the standard-library smart pointers do not degrade implicitly in contexts requiring raw pointers.
As mentioned in the question, the proper way to access the underlying raw pointer from a unique_ptr
is to use get()
. This is a design feature, apparently intended to help avoid accidentally causing multiple-ownership scenarios, which would lead to undefined behavior.