1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| #ifdef __cplusplus
#ifndef CLASS_NSNULL_NULLPOINTER_DEFINED
#define CLASS_NSNULL_NULLPOINTER_DEFINED
namespace NsNull
{
//When using COM under Visual C++, an inline function in comdef.h uses the
//Visual-specific keyword __uuidof() with NULL, which returns a null UUID.
//
//If this is needed, define CLASS_NSNULL_NULLPOINTER_NEED_UUID before
//including this file
#ifdef CLASS_NSNULL_NULLPOINTER_NEED_UUID
#define CLASS_NSNULL_NULLPOINTER_DECLSPECS DECLSPEC_UUID("00000000-0000-0000-0000-000000000000")
#else
#define CLASS_NSNULL_NULLPOINTER_DECLSPECS
#endif
//NullPointer class:
//A class that is implicitely convertible into NULL.
//
//It is not recommended to include this file before standard header files.
//However, it can be done. In this case, when including before MFC headers,
//defining CLASS_NSNULL_NULLPOINTER_NEED_LPARAM might be required, because
//some inline functions in MFC pass directly NULL as a LPARAM.
class CLASS_NSNULL_NULLPOINTER_DECLSPECS NullPointer
{
public:
inline explicit NullPointer()
{ }
template< class T >
inline operator T* (void) const
{
T* ptr = 0;
return ptr;
}
//Hacks for WPARAM and LPARAM, needed by some MFC files
#ifdef CLASS_NSNULL_NULLPOINTER_NEED_WPARAM
inline operator WPARAM (void) const
{
WPARAM wParam = 0;
return wParam;
}
#endif// ! CLASS_NSNULL_NULLPOINTER_NEED_WPARAM
#ifdef CLASS_NSNULL_NULLPOINTER_NEED_LPARAM
inline operator LPARAM (void) const
{
LPARAM lParam = 0;
return lParam;
}
#endif// ! CLASS_NSNULL_NULLPOINTER_NEED_LPARAM
};
}//namespace NsNull
#endif// ! CLASS_NSNULL_NULLPOINTER_DEFINED
#undef NULL
#define NULL (NsNull::NullPointer())
#endif// __cplusplus |
Partager