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