]> git.saurik.com Git - wxWidgets.git/blob - include/wx/meta/pod.h
Don't require skipping "page changed" event in wxMSW wxNotebook.
[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 // RCS-ID: $Id$
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_META_POD_H_
12 #define _WX_META_POD_H_
13
14 #include "wx/defs.h"
15
16 //
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>.
20 //
21
22 // This macro declares something called "value" inside a class declaration.
23 //
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 }
29 #else
30 #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) static const bool value = val
31 #endif
32
33 // Helper to decide if an object of type T is POD (Plain Old Data)
34 template<typename T>
35 struct wxIsPod
36 {
37 wxDEFINE_TEMPLATE_BOOL_VALUE(false);
38 };
39
40 // Macro to add wxIsPod<T> specialization for given type that marks it
41 // as Plain Old Data:
42 #define WX_DECLARE_TYPE_POD(type) \
43 template<> struct wxIsPod<type> \
44 { \
45 wxDEFINE_TEMPLATE_BOOL_VALUE(true); \
46 };
47
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)
62 #endif
63 #ifdef wxLongLong_t
64 WX_DECLARE_TYPE_POD(wxLongLong_t)
65 WX_DECLARE_TYPE_POD(wxULongLong_t)
66 #endif
67
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)
72
73 // pointers are Plain Old Data:
74 template<typename T>
75 struct wxIsPod<T*>
76 {
77 static const bool value = true;
78 };
79
80 template<typename T>
81 struct wxIsPod<const T*>
82 {
83 static const bool value = true;
84 };
85
86 #endif // !VC++ < 7
87
88 #endif // _WX_META_POD_H_