Reputation: 718
I'm designing c++/CLI library with many dll's and internal usage of opencv. OpenCV matrices are passed between theese dll and that is origin of my question:
Do you how to force cv::Mat to behave similar to std::unique_ptr, std::shared_ptr and std::weak_ptr?
A far as I know cv::Mat behave similar to std::shared_ptr (with reference counter), but what about other types of smart pointers?
Upvotes: 1
Views: 1995
Reputation: 179991
By far the easiest method would be std::unique_ptr<cv::Mat>
. It has the additional benefit of being obvious to future maintainers.
By itself this won't prevent others from holding on their own cv::Mat
copy which would share ownership. You can partially prevent that: If ownership could be shared, clone
the cv::Matbefore putting it into the
std::unique_ptr`. But anyone can later create additional cv::Mat's sharing ownership.
Upvotes: 1