pre_allocated_array.h

来自「hl2 source code. Do not use it illegal.」· C头文件 代码 · 共 39 行

H
39
字号
#ifndef HK_BASE_PRE_ALLOCATED_ARRAY_H
#define HK_BASE_PRE_ALLOCATED_ARRAY_H


#ifndef HK_BASE_BASE_H
#	error Include <hk_base/base.h> instead.
#endif


// array class where the elems are allocated just behind
// the array itself
template<class T>
class hk_Pre_Allocated_Array : public hk_Array<T>
{	
	protected:

		inline hk_Pre_Allocated_Array(T* elems, int initial_size)
			:  hk_Array<T>( elems, initial_size)
		{
			;
		} 

	public:

		inline ~hk_Pre_Allocated_Array()
		{
			if ( get_elems() == (T*)(this+1))
			{
				m_elems = 0;
			}
			
		}
	HK_NEW_DELETE_FUNCTION_CLASS( hk_Pre_Allocated_Array<T>, HK_MEMORY_CLASS_ARRAY )		// e.g. defines new as   new (hk_Memory *)hk_Class_Name and delete var, hk_Memory *
};


#endif /* HK_PRE_ALLOCATED_ARRAY_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?