#ifndef WINVER
#define WINVER 0x0500
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0500
#endif
#ifndef _WIN32_IE
#define _WIN32_IE 0x0500
#endif
#ifndef __FILE_LINE__
#ifndef __STRINGER__
#define __STRINGER__(x) #x
#else
#error "__STRINGER__ has been defined"
#endif//__STRINGER__
//1:expand macro value
//2:value to string
#ifndef __STR_MACRO__
#define __STR_MACRO__(x) __STRINGER__(x)
#else
#error "__STR_MACRO__ has been defined"
#endif//__STR_MACRO__
#define __FILE_LINE__ __FILE__ "("__STR_MACRO__(__LINE__)"):/t"
#endif //__FILE_LINE__
//use example
//#pragma message(__FILE_LINE__"some message")
#ifndef ARRAY_ITEMS
#define ARRAY_ITEMS(array) (sizeof(array)/sizeof(array[0]))
#endif//ARRAY_ITEMS
#ifndef ARRAY_BEGIN
#define ARRAY_BEGIN(array) (&array[0])
#endif//ARRAY_BEGIN
#ifndef ARRAY_END
#define ARRAY_END(array) (ARRAY_BEGIN(array)+ARRAY_ITEMS(array))
#endif//ARRAY_END
#ifndef FIND_ARRAY_ITEM
#include <algorithm>
#define FIND_ARRAY_ITEM(array, value) (std::find(ARRAY_BEGIN(array),ARRAY_END(array),value)-ARRAY_BEGIN(array))
#endif//FIND_ARRAY_ITEM
#ifndef HAS_MASK
#define HAS_MASK(val, mask) (mask==(val&mask))
#endif //HAS_MASK
template<class T>
inline void SafeDelete(T*& p)
{
if(NULL!=p)
{
delete p;
p = NULL;
}
}
template<class T>
inline T*& SafeNew(T*& p)
{
SafeDelete(p);
p = new T;
return p;
}
template<class T>
inline void SafeFree(T*& p)
{
if(NULL!=p)
{
free((void*)p);
p = NULL;
}
}
template<class T>
inline T*& SafeMalloc(T*& p, unsigned int nSize)
{
SafeFree(p);
p = (T*)malloc(nSize);
return p;
}
template< class T, eMemType eMT=eNew>
class CSmartPtr
{
private:
//strange declaretion
template<class U, eMemType eUMT=eMT> friend class CSmartPtr;
.........