mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
fixed warnings; restored fixed_size parameter in AutoBuffer
This commit is contained in:
@@ -109,7 +109,7 @@ template<typename _Tp> class CV_EXPORTS MatIterator_;
|
||||
template<typename _Tp> class CV_EXPORTS MatConstIterator_;
|
||||
template<typename _Tp> class CV_EXPORTS MatCommaInitializer_;
|
||||
|
||||
template<typename _Tp> class CV_EXPORTS AutoBuffer;
|
||||
template<typename _Tp, size_t fixed_size = 1024/sizeof(_Tp)+8> class CV_EXPORTS AutoBuffer;
|
||||
|
||||
CV_EXPORTS string format( const char* fmt, ... );
|
||||
CV_EXPORTS string tempfile( const char* suffix CV_DEFAULT(0));
|
||||
@@ -3093,11 +3093,10 @@ public:
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
template<typename _Tp> class CV_EXPORTS AutoBuffer
|
||||
template<typename _Tp, size_t fixed_size> class CV_EXPORTS AutoBuffer
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
enum { fixed_size = 1024/sizeof(_Tp)+8, buffer_padding = (int)((16 + sizeof(_Tp) - 1)/sizeof(_Tp)) };
|
||||
|
||||
//! the default contructor
|
||||
AutoBuffer();
|
||||
@@ -3105,9 +3104,9 @@ public:
|
||||
AutoBuffer(size_t _size);
|
||||
|
||||
//! the copy constructor
|
||||
AutoBuffer(const AutoBuffer<_Tp>& buf);
|
||||
AutoBuffer(const AutoBuffer<_Tp, fixed_size>& buf);
|
||||
//! the assignment operator
|
||||
AutoBuffer<_Tp>& operator = (const AutoBuffer<_Tp>& buf);
|
||||
AutoBuffer<_Tp, fixed_size>& operator = (const AutoBuffer<_Tp, fixed_size>& buf);
|
||||
|
||||
//! destructor. calls deallocate()
|
||||
~AutoBuffer();
|
||||
@@ -3117,7 +3116,7 @@ public:
|
||||
//! deallocates the buffer if it was dynamically allocated
|
||||
void deallocate();
|
||||
//! resizes the buffer and preserves the content
|
||||
void resize(size_t _size);
|
||||
void resize(size_t _size);
|
||||
//! returns the current buffer size
|
||||
size_t size() const;
|
||||
//! returns pointer to the real buffer, stack-allocated or head-allocated
|
||||
@@ -3131,7 +3130,7 @@ protected:
|
||||
//! size of the real buffer
|
||||
size_t sz;
|
||||
//! pre-allocated buffer
|
||||
_Tp buf[fixed_size+buffer_padding];
|
||||
_Tp buf[fixed_size];
|
||||
};
|
||||
|
||||
/////////////////////////// multi-dimensional dense matrix //////////////////////////
|
||||
|
||||
@@ -2534,21 +2534,23 @@ inline Point LineIterator::pos() const
|
||||
|
||||
/////////////////////////////// AutoBuffer ////////////////////////////////////////
|
||||
|
||||
template<typename _Tp> inline AutoBuffer<_Tp>::AutoBuffer()
|
||||
template<typename _Tp, size_t fixed_size> inline
|
||||
AutoBuffer<_Tp, fixed_size>::AutoBuffer()
|
||||
{
|
||||
ptr = buf;
|
||||
sz = fixed_size;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline AutoBuffer<_Tp>::AutoBuffer(size_t _size)
|
||||
template<typename _Tp, size_t fixed_size> inline
|
||||
AutoBuffer<_Tp, fixed_size>::AutoBuffer(size_t _size)
|
||||
{
|
||||
ptr = buf;
|
||||
sz = fixed_size;
|
||||
allocate(_size);
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline AutoBuffer<_Tp>::AutoBuffer(const AutoBuffer<_Tp>& abuf )
|
||||
template<typename _Tp, size_t fixed_size> inline
|
||||
AutoBuffer<_Tp, fixed_size>::AutoBuffer(const AutoBuffer<_Tp, fixed_size>& abuf )
|
||||
{
|
||||
ptr = buf;
|
||||
sz = fixed_size;
|
||||
@@ -2557,8 +2559,8 @@ inline AutoBuffer<_Tp>::AutoBuffer(const AutoBuffer<_Tp>& abuf )
|
||||
ptr[i] = abuf.ptr[i];
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline AutoBuffer<_Tp>& AutoBuffer<_Tp>::operator = (const AutoBuffer<_Tp>& abuf )
|
||||
template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>&
|
||||
AutoBuffer<_Tp, fixed_size>::operator = (const AutoBuffer<_Tp, fixed_size>& abuf)
|
||||
{
|
||||
if( this != &abuf )
|
||||
{
|
||||
@@ -2570,10 +2572,12 @@ inline AutoBuffer<_Tp>& AutoBuffer<_Tp>::operator = (const AutoBuffer<_Tp>& abuf
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline AutoBuffer<_Tp>::~AutoBuffer()
|
||||
template<typename _Tp, size_t fixed_size> inline
|
||||
AutoBuffer<_Tp, fixed_size>::~AutoBuffer()
|
||||
{ deallocate(); }
|
||||
|
||||
template<typename _Tp> inline void AutoBuffer<_Tp>::allocate(size_t _size)
|
||||
template<typename _Tp, size_t fixed_size> inline void
|
||||
AutoBuffer<_Tp, fixed_size>::allocate(size_t _size)
|
||||
{
|
||||
if(_size <= sz)
|
||||
{
|
||||
@@ -2588,7 +2592,8 @@ template<typename _Tp> inline void AutoBuffer<_Tp>::allocate(size_t _size)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _Tp> inline void AutoBuffer<_Tp>::deallocate()
|
||||
template<typename _Tp, size_t fixed_size> inline void
|
||||
AutoBuffer<_Tp, fixed_size>::deallocate()
|
||||
{
|
||||
if( ptr != buf )
|
||||
{
|
||||
@@ -2598,7 +2603,8 @@ template<typename _Tp> inline void AutoBuffer<_Tp>::deallocate()
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _Tp> inline void AutoBuffer<_Tp>::resize(size_t _size)
|
||||
template<typename _Tp, size_t fixed_size> inline void
|
||||
AutoBuffer<_Tp, fixed_size>::resize(size_t _size)
|
||||
{
|
||||
if(_size <= sz)
|
||||
{
|
||||
@@ -2621,13 +2627,16 @@ template<typename _Tp> inline void AutoBuffer<_Tp>::resize(size_t _size)
|
||||
delete[] prevptr;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline size_t AutoBuffer<_Tp>::size() const
|
||||
template<typename _Tp, size_t fixed_size> inline size_t
|
||||
AutoBuffer<_Tp, fixed_size>::size() const
|
||||
{ return sz; }
|
||||
|
||||
template<typename _Tp> inline AutoBuffer<_Tp>::operator _Tp* ()
|
||||
template<typename _Tp, size_t fixed_size> inline
|
||||
AutoBuffer<_Tp, fixed_size>::operator _Tp* ()
|
||||
{ return ptr; }
|
||||
|
||||
template<typename _Tp> inline AutoBuffer<_Tp>::operator const _Tp* () const
|
||||
template<typename _Tp, size_t fixed_size> inline
|
||||
AutoBuffer<_Tp, fixed_size>::operator const _Tp* () const
|
||||
{ return ptr; }
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user