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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.