I noticed a behaviour in some library that I am compiling, which was slightly unexpected and wanted to clarify that.
There is a class which has a method of the following form:
void notify(Frame & frame);
Now, there is a caller which uses a unique_ptr
as follows:
std::unique_ptr <Frame> localFrame (new Frame(rows, cols));
Now when it calls the method it does:
obj->notify(*localFrame);
So this relies on some implicit conversion of the underlying pointer to a reference.
My question is that is this cross platform and expected behaviour? Is there any use for me to do something something like:
obj->notify(*localFrame->get());
"Some implicit conversion" is std::unique_ptr::operator* which is quite a standard operator that returns a reference to the pointed-to object. You don't need to overcomplicate it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With