From: Anatoly Baksheev Date: Fri, 21 Dec 2012 19:27:29 +0000 (+0400) Subject: Smart operators for smart Ptr (feature #2637) X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~4046^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a09b973c2eb47a13f316c3987feefaa989c6be8a;p=platform%2Fupstream%2Fopencv.git Smart operators for smart Ptr (feature #2637) --- diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index 5b8ee63..94d7526 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -1277,12 +1277,13 @@ public: operator _Tp* (); operator const _Tp*() const; - bool operator==(const Ptr<_Tp>& ptr) const; - _Tp* obj; //< the object pointer. int* refcount; //< the associated reference counter }; +template bool operator==(Ptr const & a, Ptr const & b); +template bool operator!=(Ptr const & a, Ptr const & b); + //////////////////////// Input/Output Array Arguments ///////////////////////////////// diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index aaabe5f..eaae0c0 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -2691,10 +2691,11 @@ template template inline const Ptr<_Tp2> Ptr<_Tp>:: return p; } -template inline bool Ptr<_Tp>::operator==(const Ptr<_Tp>& _ptr) const -{ - return refcount == _ptr.refcount; -} +template inline bool operator==(const Ptr<_Tp>& a, const Ptr<_Tp2>& b) { return a.refcount == b.refcount; } +template inline bool operator!=(const Ptr<_Tp>& a, const Ptr<_Tp2>& b) { return a.refcount != b.refcount; } + + + //// specializied implementations of Ptr::delete_obj() for classic OpenCV types diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index aee20b3..f87364c 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -5519,7 +5519,7 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat ) return; } Ptr m = (CvSparseMat*)cvRead((CvFileStorage*)node.fs, (CvFileNode*)*node); - CV_Assert(CV_IS_SPARSE_MAT(m)); + CV_Assert(CV_IS_SPARSE_MAT(m.obj)); SparseMat(m).copyTo(mat); } diff --git a/modules/features2d/src/matchers.cpp b/modules/features2d/src/matchers.cpp index aac9e6b..e82b173 100644 --- a/modules/features2d/src/matchers.cpp +++ b/modules/features2d/src/matchers.cpp @@ -616,7 +616,7 @@ void FlannBasedMatcher::write( FileStorage& fs) const { fs << "indexParams" << "["; - if (indexParams != 0) + if (indexParams) { std::vector names; std::vector types; @@ -667,7 +667,7 @@ void FlannBasedMatcher::write( FileStorage& fs) const fs << "]" << "searchParams" << "["; - if (searchParams != 0) + if (searchParams) { std::vector names; std::vector types;