generic_type ref-counting pointer class for C/C++ objects
/*!
Smart pointer to dynamically allocated objects.
This is template pointer-wrapping class that stores the associated reference counter along with the
object pointer. The class is similar to std::smart_ptr<> from the recent addons to the C++ standard,
but is shorter to write :) and self-contained (i.e. does add any dependency on the compiler or an external library).
Basically, you can use "Ptr<MyObjectType> ptr" (or faster "const Ptr<MyObjectType>& ptr" for read-only access)
everywhere instead of "MyObjectType* ptr", where MyObjectType is some C structure or a C++ class.
To make it all work, you need to specialize Ptr<>::delete_obj(), like:
\code
template<> void Ptr<MyObjectType>::delete_obj() { call_destructor_func(obj); }
\endcode
\note{if MyObjectType is a C++ class with
opencv 智能指针 Ptr
最新推荐文章于 2024-06-07 11:20:26 发布