]> git.saurik.com Git - wxWidgets.git/blob - include/wx/meta/pod.h
Add wxActivateEvent::GetActivationReason().
[wxWidgets.git] / include / wx / meta / pod.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/meta/pod.h
3 // Purpose: Test if a type is POD
4 // Author: Vaclav Slavik, Jaakko Salli
5 // Created: 2010-06-14
6 // Copyright: (c) wxWidgets team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_META_POD_H_
11 #define _WX_META_POD_H_
12
13 #include "wx/defs.h"
14
15 //
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>.
19 //
20
21 // This macro declares something called "value" inside a class declaration.
22 //
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 }
28 #else
29 #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) static const bool value = val
30 #endif
31
32 // Helper to decide if an object of type T is POD (Plain Old Data)
33 template<typename T>
34 struct wxIsPod
35 {
36 wxDEFINE_TEMPLATE_BOOL_VALUE(false);
37 };
38
39 // Macro to add wxIsPod<T> specialization for given type that marks it
40 // as Plain Old Data:
41 #define WX_DECLARE_TYPE_POD(type) \
42 template<> struct wxIsPod<type> \
43 { \
44 wxDEFINE_TEMPLATE_BOOL_VALUE(true); \
45 };
46
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)
61 #endif
62 #ifdef wxLongLong_t
63 WX_DECLARE_TYPE_POD(wxLongLong_t)
64 WX_DECLARE_TYPE_POD(wxULongLong_t)
65 #endif
66
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)
71
72 // pointers are Plain Old Data:
73 template<typename T>
74 struct wxIsPod<T*>
75 {
76 static const bool value = true;
77 };
78
79 template<typename T>
80 struct wxIsPod<const T*>
81 {
82 static const bool value = true;
83 };
84
85 #endif // !VC++ < 7
86
87 #endif // _WX_META_POD_H_