c++/cpp中auto_ptr用法分析

本文分析了C++中auto_ptr的一个常见问题。通过示例代码展示了auto_ptr不使用引用计数机制可能导致的段错误,并深入探讨了其内部实现原理。

本文将分析一下c++中自带的auto_ptr在使用中需要注意的一个问题。首先看一段代码:

// auto_ptr example
#include <iostream>
#include <memory>
using namespace std;
int main () 
 {
        auto_ptr<int> p1 (new int);
        *p1.get()=10;

        {
        	auto_ptr<int> p2 (p1);
        	cout << "p2 points to " << *p2 << "\n";
        }
        cout << "p1 points to " << *p1 << "\n";
        return 0;
}
猜测一下这段程序的输出?如果不出意外,得到的结果应该是如下这样的。

p2 points to 10
Segmentation fault (core dumped)

你可能会奇怪,为什么对p1的引用会出现段错误了呢?好吧,我们来看一下auto_ptr的源代码。

namespace std {
    // auxiliary type to enable copies and assignments (now global)
    template<class Y>
    struct auto_ptr_ref {
        Y* yp;
        auto_ptr_ref (Y* rhs)
         : yp(rhs) {
        }
    };

    template<class T>
    class auto_ptr
    {
    private:
        T* ap;    // refers to the actual owned object (if any)
    public:
        typedef T element_type;

        // constructor
        explicit auto_ptr (T* ptr = 0) throw() : ap(ptr) { }

        // copy constructors (with implicit conversion)
        // - note: nonconstant parameter
        auto_ptr (auto_ptr& rhs) throw() : ap(rhs.release()) { }

        template<class Y>
        auto_ptr (auto_ptr<Y>& rhs) throw() : ap(rhs.release()) { }

        // assignments (with implicit conversion)
        // - note: nonconstant parameter
        auto_ptr& operator= (auto_ptr& rhs) throw()
        {
            reset(rhs.release());
            return *this;
        }
        template<class Y>
        auto_ptr& operator= (auto_ptr<Y>& rhs) throw()
        {
            reset(rhs.release());
            return *this;
        }

        // destructor, 注意这里释放内存。。
        ~auto_ptr() throw()
        {
            delete ap;
        }

        // value access
        T* get() const throw()
        {
            return ap;
        }
        T& operator*() const throw()
        {
            return *ap;
        }
        T* operator->() const throw()
        {
            return ap;
        }

        // release ownership
        T* release() throw()
        {
            T* tmp(ap);
            ap = 0;
            return tmp;
        }

        // reset value
        void reset (T* ptr=0) throw()
        {
            if (ap != ptr)
            {
                delete ap;
                ap = ptr;
            }
        }
	}
}
一般我们会认为智能指针都是采用一种引用计数的方式来管理已分配的内存,也就是说会在最后一个智能指针对象调用析构函数时将分配的内存释放掉,然而仔细看auto_ptr的源代码会发现,其实它的实现并没有采用引用计数的方式来实现,因为只要任何一个auto_ptr对象调用析构函数,内存就一定会被释放掉,这就是为何对p1的引用会出现段错误,因为p2在对p1引用之前已经将分配的内存给释放掉了。


/usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(cv::Ptr<Y>&&) [with Y = cv::detail::RotationWarper; T = cv::WarperCreator]’: /home/a/stitch/stitch_diff_warper.cpp:137:68: required from here /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: error: no matching function for call to ‘std::shared_ptr<cv::WarperCreator>::shared_ptr(std::remove_reference<cv::Ptr<cv::detail::RotationWarper>&>::type)’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ In file included from /usr/include/c++/13/memory:80, from /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:11: /usr/include/c++/13/bits/shared_ptr.h:463:9: note: candidate: ‘template<class _Alloc, class ... _Args> std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Args = _Alloc; _Tp = cv::WarperCreator]’ 463 | shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:463:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: ‘cv::Ptr<cv::detail::RotationWarper>’ is not derived from ‘std::_Sp_alloc_shared_tag<_Tp>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:395:9: note: candidate: ‘template<class _Yp, class _Del, class> std::shared_ptr<_Tp>::shared_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Del = _Yp; <template-parameter-2-3> = _Del; _Tp = cv::WarperCreator]’ 395 | shared_ptr(unique_ptr<_Yp, _Del>&& __r) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:395:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: ‘std::remove_reference<cv::Ptr<cv::detail::RotationWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::RotationWarper>’} is not derived from ‘std::unique_ptr<_Tp, _Dp>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:387:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Up>&&) [with _Yp = _Tp1; _Tp = cv::WarperCreator]’ 387 | shared_ptr(auto_ptr<_Yp>&& __r); | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:387:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: ‘std::remove_reference<cv::Ptr<cv::detail::RotationWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::RotationWarper>’} is not derived from ‘std::auto_ptr<_Up>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:380:18: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Yp>&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 380 | explicit shared_ptr(const weak_ptr<_Yp>& __r) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:380:18: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: ‘std::remove_reference<cv::Ptr<cv::detail::RotationWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::RotationWarper>’} is not derived from ‘const std::weak_ptr<_Tp>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:368:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Yp>&&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 368 | shared_ptr(shared_ptr<_Yp>&& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:368:9: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/shared_ptr.h: In substitution of ‘template<class _Tp> template<class ... _Args> using std::shared_ptr<_Tp>::_Constructible = typename std::enable_if<std::is_constructible<std::__shared_ptr<_Tp>, _Args ...>::value>::type [with _Args = {std::shared_ptr<cv::detail::RotationWarper>}; _Tp = cv::WarperCreator]’: /usr/include/c++/13/bits/shared_ptr.h:367:30: required from ‘cv::Ptr<T>::Ptr(cv::Ptr<Y>&&) [with Y = cv::detail::RotationWarper; T = cv::WarperCreator]’ /home/a/stitch/stitch_diff_warper.cpp:137:68: required from here /usr/include/c++/13/bits/shared_ptr.h:178:15: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ 178 | using _Constructible = typename enable_if< | ^~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(cv::Ptr<Y>&&) [with Y = cv::detail::RotationWarper; T = cv::WarperCreator]’: /home/a/stitch/stitch_diff_warper.cpp:137:68: required from here /usr/include/c++/13/bits/shared_ptr.h:351:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Yp>&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 351 | shared_ptr(const shared_ptr<_Yp>& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:351:9: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/shared_ptr.h: In substitution of ‘template<class _Tp> template<class ... _Args> using std::shared_ptr<_Tp>::_Constructible = typename std::enable_if<std::is_constructible<std::__shared_ptr<_Tp>, _Args ...>::value>::type [with _Args = {const std::shared_ptr<cv::detail::RotationWarper>&}; _Tp = cv::WarperCreator]’: /usr/include/c++/13/bits/shared_ptr.h:350:9: required from ‘cv::Ptr<T>::Ptr(cv::Ptr<Y>&&) [with Y = cv::detail::RotationWarper; T = cv::WarperCreator]’ /home/a/stitch/stitch_diff_warper.cpp:137:68: required from here /usr/include/c++/13/bits/shared_ptr.h:178:15: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ 178 | using _Constructible = typename enable_if< | ^~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(cv::Ptr<Y>&&) [with Y = cv::detail::RotationWarper; T = cv::WarperCreator]’: /home/a/stitch/stitch_diff_warper.cpp:137:68: required from here /usr/include/c++/13/bits/shared_ptr.h:311:9: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Yp>&, element_type*) [with _Tp = cv::WarperCreator]’ 311 | shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:311:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: candidate expects 2 arguments, 1 provided 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:287:9: note: candidate: ‘template<class _Deleter, class _Alloc> std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t, _Deleter, _Alloc) [with _Alloc = _Deleter; _Tp = cv::WarperCreator]’ 287 | shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:287:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: candidate expects 3 arguments, 1 provided 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:268:9: note: candidate: ‘template<class _Yp, class _Deleter, class _Alloc, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter, _Alloc) [with _Deleter = _Yp; _Alloc = _Deleter; <template-parameter-2-4> = _Alloc; _Tp = cv::WarperCreator]’ 268 | shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:268:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::RotationWarper>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:248:9: note: candidate: ‘template<class _Deleter> std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t, _Deleter) [with _Tp = cv::WarperCreator]’ 248 | shared_ptr(nullptr_t __p, _Deleter __d) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:248:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: candidate expects 2 arguments, 1 provided 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:231:9: note: candidate: ‘template<class _Yp, class _Deleter, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter) [with _Deleter = _Yp; <template-parameter-2-3> = _Deleter; _Tp = cv::WarperCreator]’ 231 | shared_ptr(_Yp* __p, _Deleter __d) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:231:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::RotationWarper>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:214:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 214 | shared_ptr(_Yp* __p) : __shared_ptr<_Tp>(__p) { } | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:214:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:89:94: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::RotationWarper>’ 89 | template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:535:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Tp>&, std::nothrow_t) [with _Tp = cv::WarperCreator]’ 535 | shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:535:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/13/bits/shared_ptr.h:412:17: note: candidate: ‘constexpr std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t) [with _Tp = cv::WarperCreator; std::nullptr_t = std::nullptr_t]’ 412 | constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { } | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:412:28: note: no known conversion for argument 1 from ‘std::remove_reference<cv::Ptr<cv::detail::RotationWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::RotationWarper>’} to ‘std::nullptr_t’ 412 | constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { } | ^~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:359:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Tp>&&) [with _Tp = cv::WarperCreator]’ 359 | shared_ptr(shared_ptr&& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:359:31: note: no known conversion for argument 1 from ‘std::remove_reference<cv::Ptr<cv::detail::RotationWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::RotationWarper>’} to ‘std::shared_ptr<cv::WarperCreator>&&’ 359 | shared_ptr(shared_ptr&& __r) noexcept | ~~~~~~~~~~~~~^~~ /usr/include/c++/13/bits/shared_ptr.h:204:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Tp>&) [with _Tp = cv::WarperCreator]’ 204 | shared_ptr(const shared_ptr&) noexcept = default; ///< Copy constructor | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:204:18: note: no known conversion for argument 1 from ‘std::remove_reference<cv::Ptr<cv::detail::RotationWarper>&>::type’ {aka ‘cv::Ptr<cv::detail::RotationWarper>’} to ‘const std::shared_ptr<cv::WarperCreator>&’ 204 | shared_ptr(const shared_ptr&) noexcept = default; ///< Copy constructor | ^~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:202:17: note: candidate: ‘constexpr std::shared_ptr<_Tp>::shared_ptr() [with _Tp = cv::WarperCreator]’ 202 | constexpr shared_ptr() noexcept : __shared_ptr<_Tp>() { } | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:202:17: note: candidate expects 0 arguments, 1 provided /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(const cv::Ptr<Y>&) [with Y = cv::detail::RotationWarper; T = cv::WarperCreator]’: /home/a/stitch/stitch_diff_warper.cpp:140:32: required from here /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: error: no matching function for call to ‘std::shared_ptr<cv::WarperCreator>::shared_ptr(const cv::Ptr<cv::detail::RotationWarper>&)’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:463:9: note: candidate: ‘template<class _Alloc, class ... _Args> std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Args = _Alloc; _Tp = cv::WarperCreator]’ 463 | shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:463:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: ‘cv::Ptr<cv::detail::RotationWarper>’ is not derived from ‘std::_Sp_alloc_shared_tag<_Tp>’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:395:9: note: candidate: ‘template<class _Yp, class _Del, class> std::shared_ptr<_Tp>::shared_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Del = _Yp; <template-parameter-2-3> = _Del; _Tp = cv::WarperCreator]’ 395 | shared_ptr(unique_ptr<_Yp, _Del>&& __r) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:395:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: types ‘std::unique_ptr<_Tp, _Dp>’ and ‘const cv::Ptr<cv::detail::RotationWarper>’ have incompatible cv-qualifiers 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:387:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Up>&&) [with _Yp = _Tp1; _Tp = cv::WarperCreator]’ 387 | shared_ptr(auto_ptr<_Yp>&& __r); | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:387:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: types ‘std::auto_ptr<_Up>’ and ‘const cv::Ptr<cv::detail::RotationWarper>’ have incompatible cv-qualifiers 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:380:18: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Yp>&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 380 | explicit shared_ptr(const weak_ptr<_Yp>& __r) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:380:18: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: ‘const cv::Ptr<cv::detail::RotationWarper>’ is not derived from ‘const std::weak_ptr<_Tp>’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:368:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Yp>&&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 368 | shared_ptr(shared_ptr<_Yp>&& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:368:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: types ‘std::shared_ptr<_Tp>’ and ‘const cv::Ptr<cv::detail::RotationWarper>’ have incompatible cv-qualifiers 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:351:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Yp>&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 351 | shared_ptr(const shared_ptr<_Yp>& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:351:9: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/shared_ptr.h:311:9: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Yp>&, element_type*) [with _Tp = cv::WarperCreator]’ 311 | shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:311:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: candidate expects 2 arguments, 1 provided 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:287:9: note: candidate: ‘template<class _Deleter, class _Alloc> std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t, _Deleter, _Alloc) [with _Alloc = _Deleter; _Tp = cv::WarperCreator]’ 287 | shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:287:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: candidate expects 3 arguments, 1 provided 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:268:9: note: candidate: ‘template<class _Yp, class _Deleter, class _Alloc, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter, _Alloc) [with _Deleter = _Yp; _Alloc = _Deleter; <template-parameter-2-4> = _Alloc; _Tp = cv::WarperCreator]’ 268 | shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:268:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::RotationWarper>’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:248:9: note: candidate: ‘template<class _Deleter> std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t, _Deleter) [with _Tp = cv::WarperCreator]’ 248 | shared_ptr(nullptr_t __p, _Deleter __d) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:248:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: candidate expects 2 arguments, 1 provided 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:231:9: note: candidate: ‘template<class _Yp, class _Deleter, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter) [with _Deleter = _Yp; <template-parameter-2-3> = _Deleter; _Tp = cv::WarperCreator]’ 231 | shared_ptr(_Yp* __p, _Deleter __d) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:231:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::RotationWarper>’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:214:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 214 | shared_ptr(_Yp* __p) : __shared_ptr<_Tp>(__p) { } | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:214:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::RotationWarper>’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:535:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Tp>&, std::nothrow_t) [with _Tp = cv::WarperCreator]’ 535 | shared_ptr(const weak_ptr<_Tp>& __r, std::nothrow_t) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:535:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/13/bits/shared_ptr.h:412:17: note: candidate: ‘constexpr std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t) [with _Tp = cv::WarperCreator; std::nullptr_t = std::nullptr_t]’ 412 | constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { } | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:412:28: note: no known conversion for argument 1 from ‘const cv::Ptr<cv::detail::RotationWarper>’ to ‘std::nullptr_t’ 412 | constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { } | ^~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:359:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Tp>&&) [with _Tp = cv::WarperCreator]’ 359 | shared_ptr(shared_ptr&& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:359:31: note: no known conversion for argument 1 from ‘const cv::Ptr<cv::detail::RotationWarper>’ to ‘std::shared_ptr<cv::WarperCreator>&&’ 359 | shared_ptr(shared_ptr&& __r) noexcept | ~~~~~~~~~~~~~^~~ /usr/include/c++/13/bits/shared_ptr.h:204:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Tp>&) [with _Tp = cv::WarperCreator]’ 204 | shared_ptr(const shared_ptr&) noexcept = default; ///< Copy constructor | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:204:18: note: no known conversion for argument 1 from ‘const cv::Ptr<cv::detail::RotationWarper>’ to ‘const std::shared_ptr<cv::WarperCreator>&’ 204 | shared_ptr(const shared_ptr&) noexcept = default; ///< Copy constructor | ^~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:202:17: note: candidate: ‘constexpr std::shared_ptr<_Tp>::shared_ptr() [with _Tp = cv::WarperCreator]’ 202 | constexpr shared_ptr() noexcept : __shared_ptr<_Tp>() { } | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:202:17: note: candidate expects 0 arguments, 1 provided /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(const std::false_type&, Y*) [with Y = cv::Ptr<cv::detail::PlaneWarper>(); T = cv::detail::RotationWarper; std::false_type = std::integral_constant<bool, false>]’: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:103:57: required from ‘cv::Ptr<T>::Ptr(Y*) [with Y = cv::Ptr<cv::detail::PlaneWarper>(); T = cv::detail::RotationWarper]’ /usr/include/c++/13/bits/invoke.h:114:35: required from ‘constexpr std::enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> std::__invoke_r(_Callable&&, _Args&& ...) [with _Res = cv::Ptr<cv::detail::RotationWarper>; _Callable = main(int, char**)::<lambda()>&; _Args = {}; enable_if_t<is_invocable_r_v<_Res, _Callable, _Args ...>, _Res> = cv::Ptr<cv::detail::RotationWarper>]’ /usr/include/c++/13/bits/std_function.h:290:30: required from ‘static _Res std::_Function_handler<_Res(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Res = cv::Ptr<cv::detail::RotationWarper>; _Functor = main(int, char**)::<lambda()>; _ArgTypes = {}]’ /usr/include/c++/13/bits/std_function.h:451:21: required from ‘std::function<_Res(_ArgTypes ...)>::function(_Functor&&) [with _Functor = main(int, char**)::<lambda()>; _Constraints = void; _Res = cv::Ptr<cv::detail::RotationWarper>; _ArgTypes = {}]’ /home/a/stitch/stitch_diff_warper.cpp:31:19: required from here /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:100:72: error: no matching function for call to ‘std::shared_ptr<cv::detail::RotationWarper>::shared_ptr(cv::Ptr<cv::detail::PlaneWarper> (*&)())’ 100 | inline Ptr(const std::false_type&, Y* ptr) : std::shared_ptr<T>(ptr) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:463:9: note: candidate: ‘template<class _Alloc, class ... _Args> std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Args = _Alloc; _Tp = cv::detail::RotationWarper]’ 463 | shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:463:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:100:72: note: mismatched types ‘std::_Sp_alloc_shared_tag<_Tp>’ and ‘cv::Ptr<cv::detail::PlaneWarper> (*)()’ 100 | inline Ptr(const std::false_type&, Y* ptr) : std::shared_ptr<T>(ptr) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:395:9: note: candidate: ‘template<class _Yp, class _Del, class> std::shared_ptr<_Tp>::shared_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Del = _Yp; <template-parameter-2-3> = _Del; _Tp = cv::detail::RotationWarper]’ 395 | shared_ptr(unique_ptr<_Yp, _Del>&& __r) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:395:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:100:72: note: mismatched types ‘std::unique_ptr<_Tp, _Dp>’ and ‘cv::Ptr<cv::detail::PlaneWarper> (*)()’ 100 | inline Ptr(const std::false_type&, Y* ptr) : std::shared_ptr<T>(ptr) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:387:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Up>&&) [with _Yp = _Tp1; _Tp = cv::detail::RotationWarper]’ 387 | shared_ptr(auto_ptr<_Yp>&& __r); | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:387:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:100:72: note: mismatched types ‘std::auto_ptr<_Up>’ and ‘cv::Ptr<cv::detail::PlaneWarper> (*)()’ 100 | inline Ptr(const std::false_type&, Y* ptr) : std::shared_ptr<T>(ptr) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:380:18: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Yp>&) [with <template-parameter-2-2> = _Yp; _Tp = cv::detail::RotationWarper]’ 380 | explicit shared_ptr(const weak_ptr<_Yp>& __r) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:380:18: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:100:72: note: mismatched types ‘const std::weak_ptr<_Tp>’ and ‘cv::Ptr<cv::detail::PlaneWarper> (*)()’ 100 | inline Ptr(const std::false_type&, Y* ptr) : std::shared_ptr<T>(ptr) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:368:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Yp>&&) [with <template-parameter-2-2> = _Yp; _Tp = cv::detail::RotationWarper]’ 368 | shared_ptr(shared_ptr<_Yp>&& __r) noexcept
07-11
In file included from /usr/local/include/opencv4/opencv2/core/cvstd.hpp:81, from /usr/local/include/opencv4/opencv2/core/base.hpp:58, from /usr/local/include/opencv4/opencv2/core.hpp:53, from /usr/local/include/opencv4/opencv2/opencv.hpp:52, from /home/a/stitch/quickopencv.h:3, from /home/a/stitch/stitch_diff_warper.cpp:1: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(const cv::Ptr<Y>&) [with Y = cv::detail::RotationWarper; T = cv::WarperCreator]’: /home/a/stitch/stitch_diff_warper.cpp:139:32: required from here /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: error: no matching function for call to ‘std::shared_ptr<cv::WarperCreator>::shared_ptr(const cv::Ptr<cv::detail::RotationWarper>&)’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ In file included from /usr/include/c++/13/memory:80, from /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:11: /usr/include/c++/13/bits/shared_ptr.h:463:9: note: candidate: ‘template<class _Alloc, class ... _Args> std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Args = _Alloc; _Tp = cv::WarperCreator]’ 463 | shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:463:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: ‘cv::Ptr<cv::detail::RotationWarper>’ is not derived from ‘std::_Sp_alloc_shared_tag<_Tp>’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:395:9: note: candidate: ‘template<class _Yp, class _Del, class> std::shared_ptr<_Tp>::shared_ptr(std::unique_ptr<_Up, _Ep>&&) [with _Del = _Yp; <template-parameter-2-3> = _Del; _Tp = cv::WarperCreator]’ 395 | shared_ptr(unique_ptr<_Yp, _Del>&& __r) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:395:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: types ‘std::unique_ptr<_Tp, _Dp>’ and ‘const cv::Ptr<cv::detail::RotationWarper>’ have incompatible cv-qualifiers 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:387:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::auto_ptr<_Up>&&) [with _Yp = _Tp1; _Tp = cv::WarperCreator]’ 387 | shared_ptr(auto_ptr<_Yp>&& __r); | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:387:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: types ‘std::auto_ptr<_Up>’ and ‘const cv::Ptr<cv::detail::RotationWarper>’ have incompatible cv-qualifiers 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:380:18: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Yp>&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 380 | explicit shared_ptr(const weak_ptr<_Yp>& __r) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:380:18: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: ‘const cv::Ptr<cv::detail::RotationWarper>’ is not derived from ‘const std::weak_ptr<_Tp>’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:368:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(std::shared_ptr<_Yp>&&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 368 | shared_ptr(shared_ptr<_Yp>&& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:368:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: types ‘std::shared_ptr<_Tp>’ and ‘const cv::Ptr<cv::detail::RotationWarper>’ have incompatible cv-qualifiers 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:351:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Yp>&) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 351 | shared_ptr(const shared_ptr<_Yp>& __r) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:351:9: note: template argument deduction/substitution failed: /usr/include/c++/13/bits/shared_ptr.h: In substitution of ‘template<class _Tp> template<class ... _Args> using std::shared_ptr<_Tp>::_Constructible = typename std::enable_if<std::is_constructible<std::__shared_ptr<_Tp>, _Args ...>::value>::type [with _Args = {const std::shared_ptr<cv::detail::RotationWarper>&}; _Tp = cv::WarperCreator]’: /usr/include/c++/13/bits/shared_ptr.h:350:9: required from ‘cv::Ptr<T>::Ptr(const cv::Ptr<Y>&) [with Y = cv::detail::RotationWarper; T = cv::WarperCreator]’ /home/a/stitch/stitch_diff_warper.cpp:139:32: required from here /usr/include/c++/13/bits/shared_ptr.h:178:15: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’ 178 | using _Constructible = typename enable_if< | ^~~~~~~~~~~~~~ /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp: In instantiation of ‘cv::Ptr<T>::Ptr(const cv::Ptr<Y>&) [with Y = cv::detail::RotationWarper; T = cv::WarperCreator]’: /home/a/stitch/stitch_diff_warper.cpp:139:32: required from here /usr/include/c++/13/bits/shared_ptr.h:311:9: note: candidate: ‘template<class _Yp> std::shared_ptr<_Tp>::shared_ptr(const std::shared_ptr<_Yp>&, element_type*) [with _Tp = cv::WarperCreator]’ 311 | shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) noexcept | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:311:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: candidate expects 2 arguments, 1 provided 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:287:9: note: candidate: ‘template<class _Deleter, class _Alloc> std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t, _Deleter, _Alloc) [with _Alloc = _Deleter; _Tp = cv::WarperCreator]’ 287 | shared_ptr(nullptr_t __p, _Deleter __d, _Alloc __a) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:287:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: candidate expects 3 arguments, 1 provided 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:268:9: note: candidate: ‘template<class _Yp, class _Deleter, class _Alloc, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter, _Alloc) [with _Deleter = _Yp; _Alloc = _Deleter; <template-parameter-2-4> = _Alloc; _Tp = cv::WarperCreator]’ 268 | shared_ptr(_Yp* __p, _Deleter __d, _Alloc __a) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:268:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::RotationWarper>’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:248:9: note: candidate: ‘template<class _Deleter> std::shared_ptr<_Tp>::shared_ptr(std::nullptr_t, _Deleter) [with _Tp = cv::WarperCreator]’ 248 | shared_ptr(nullptr_t __p, _Deleter __d) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:248:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: candidate expects 2 arguments, 1 provided 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:231:9: note: candidate: ‘template<class _Yp, class _Deleter, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*, _Deleter) [with _Deleter = _Yp; <template-parameter-2-3> = _Deleter; _Tp = cv::WarperCreator]’ 231 | shared_ptr(_Yp* __p, _Deleter __d) | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:231:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::RotationWarper>’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:214:9: note: candidate: ‘template<class _Yp, class> std::shared_ptr<_Tp>::shared_ptr(_Yp*) [with <template-parameter-2-2> = _Yp; _Tp = cv::WarperCreator]’ 214 | shared_ptr(_Yp* __p) : __shared_ptr<_Tp>(__p) { } | ^~~~~~~~~~ /usr/include/c++/13/bits/shared_ptr.h:214:9: note: template argument deduction/substitution failed: /usr/local/include/opencv4/opencv2/core/cvstd_wrapper.hpp:88:88: note: mismatched types ‘_Yp*’ and ‘cv::Ptr<cv::detail::RotationWarper>’ 88 | template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {} | ^ /usr/include/c++/13/bits/shared_ptr.h:535:7: note: candidate: ‘std::shared_ptr<_Tp>::shared_ptr(const std::weak_ptr<_Tp>&, std::nothrow_t) [with _Tp = cv::WarperCreator]’
07-11
[{ "resource": "/home/yushijin/fromGitLib/myWorkspace/20250813/rhc/tests/unit_src/test_business_state_machine.cpp", "owner": "_generated_diagnostic_collection_name_#1", "code": "ovl_no_viable_function_in_init", "severity": 8, "message": "No matching constructor for initialization of 'std::unique_ptr<RobotModule>'", "source": "clang", "startLineNumber": 100, "startColumn": 38, "endLineNumber": 100, "endColumn": 51, "relatedInformation": [ { "startLineNumber": 281, "startColumn": 2, "endLineNumber": 281, "endColumn": 12, "message": "Candidate constructor template not viable: no known conversion from 'typename std::remove_reference<shared_ptr<MockRobotModule> &>::type' (aka 'std::shared_ptr<BNE::RH::Controller::MockRobotModule>') to 'std::unique_ptr<BNE::RH::RobotModule>::pointer' (aka 'BNE::RH::RobotModule *') for 1st argument", "resource": "/usr/include/c++/11/bits/unique_ptr.h" }, { "startLineNumber": 320, "startColumn": 12, "endLineNumber": 320, "endColumn": 22, "message": "Candidate constructor template not viable: no known conversion from 'typename std::remove_reference<shared_ptr<MockRobotModule> &>::type' (aka 'std::shared_ptr<BNE::RH::Controller::MockRobotModule>') to 'std::nullptr_t' for 1st argument", "resource": "/usr/include/c++/11/bits/unique_ptr.h" }, { "startLineNumber": 327, "startColumn": 7, "endLineNumber": 327, "endColumn": 17, "message": "Candidate constructor not viable: no known conversion from 'typename std::remove_reference<shared_ptr<MockRobotModule> &>::type' (aka 'std::shared_ptr<BNE::RH::Controller::MockRobotModule>') to 'std::unique_ptr<BNE::RH::RobotModule>' for 1st argument", "resource": "/usr/include/c++/11/bits/unique_ptr.h" }, { "startLineNumber": 468, "startColumn": 7, "endLineNumber": 468, "endColumn": 17, "message": "Candidate constructor not viable: no known conversion from 'typename std::remove_reference<shared_ptr<MockRobotModule> &>::type' (aka 'std::shared_ptr<BNE::RH::Controller::MockRobotModule>') to 'const std::unique_ptr<BNE::RH::RobotModule>' for 1st argument", "resource": "/usr/include/c++/11/bits/unique_ptr.h" }, { "startLineNumber": 340, "startColumn": 2, "endLineNumber": 340, "endColumn": 12, "message": "Candidate template ignored: could not match 'unique_ptr' against 'shared_ptr'", "resource": "/usr/include/c++/11/bits/unique_ptr.h" }, { "startLineNumber": 350, "startColumn": 2, "endLineNumber": 350, "endColumn": 12, "message": "Candidate template ignored: could not match 'auto_ptr' against 'shared_ptr'", "resource": "/usr/include/c++/11/bits/unique_ptr.h" }, { "startLineNumber": 269, "startColumn": 12, "endLineNumber": 269, "endColumn": 22, "message": "Candidate constructor template not viable: requires 0 arguments, but 1 was provided", "resource": "/usr/include/c++/11/bits/unique_ptr.h" }, { "startLineNumber": 294, "startColumn": 2, "endLineNumber": 294, "endColumn": 12, "message": "Candidate constructor template not viable: requires 2 arguments, but 1 was provided", "resource": "/usr/include/c++/11/bits/unique_ptr.h" }, { "startLineNumber": 306, "startColumn": 2, "endLineNumber": 306, "endColumn": 12, "message": "Candidate constructor template not viable: requires 2 arguments, but 1 was provided", "resource": "/usr/include/c++/11/bits/unique_ptr.h" }, { "startLineNumber": 314, "startColumn": 2, "endLineNumber": 314, "endColumn": 12, "message": "Candidate constructor template not viable: requires 2 arguments, but 1 was provided", "resource": "/usr/include/c++/11/bits/unique_ptr.h" } ], "origin": "extHost2" }]
最新发布
08-15
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值