]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/meta/pod.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Test if a type is POD
4 // Author: Vaclav Slavik, Jaakko Salli
6 // Copyright: (c) wxWidgets team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_META_POD_H_
11 #define _WX_META_POD_H_
16 // TODO: Use TR1 is_pod<> implementation where available. VC9 SP1 has it
17 // in tr1 namespace, VC10 has it in std namespace. GCC 4.2 has it in
18 // <tr1/type_traits>, while GCC 4.3 and later have it in <type_traits>.
21 // This macro declares something called "value" inside a class declaration.
23 // It has to be used because VC6 doesn't handle initialization of the static
24 // variables in the class declaration itself while BCC5.82 doesn't understand
25 // enums (it compiles the template fine but can't use it later)
26 #if defined(__VISUALC__) && !wxCHECK_VISUALC_VERSION(7)
27 #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) enum { value = val }
29 #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) static const bool value = val
32 // Helper to decide if an object of type T is POD (Plain Old Data)
36 wxDEFINE_TEMPLATE_BOOL_VALUE(false);
39 // Macro to add wxIsPod<T> specialization for given type that marks it
41 #define WX_DECLARE_TYPE_POD(type) \
42 template<> struct wxIsPod<type> \
44 wxDEFINE_TEMPLATE_BOOL_VALUE(true); \
47 WX_DECLARE_TYPE_POD(bool)
48 WX_DECLARE_TYPE_POD(unsigned char)
49 WX_DECLARE_TYPE_POD(signed char)
50 WX_DECLARE_TYPE_POD(unsigned int)
51 WX_DECLARE_TYPE_POD(signed int)
52 WX_DECLARE_TYPE_POD(unsigned short int)
53 WX_DECLARE_TYPE_POD(signed short int)
54 WX_DECLARE_TYPE_POD(signed long int)
55 WX_DECLARE_TYPE_POD(unsigned long int)
56 WX_DECLARE_TYPE_POD(float)
57 WX_DECLARE_TYPE_POD(double)
58 WX_DECLARE_TYPE_POD(long double)
59 #if wxWCHAR_T_IS_REAL_TYPE
60 WX_DECLARE_TYPE_POD(wchar_t)
63 WX_DECLARE_TYPE_POD(wxLongLong_t
)
64 WX_DECLARE_TYPE_POD(wxULongLong_t
)
67 // Visual C++ 6.0 can't compile partial template specializations and as this is
68 // only an optimization, we can live with pointers not being recognized as
69 // POD types under VC6
70 #if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7)
72 // pointers are Plain Old Data:
76 static const bool value
= true;
80 struct wxIsPod
<const T
*>
82 static const bool value
= true;
87 #endif // _WX_META_POD_H_