]> git.saurik.com Git - wxWidgets.git/blame - include/wx/meta/pod.h
Added wxFONTENCODING_EUC_KR alias for wxFONTENCODING_CP949.
[wxWidgets.git] / include / wx / meta / pod.h
CommitLineData
109e2ca4
JS
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)
34template<typename T>
35struct 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
48WX_DECLARE_TYPE_POD(bool)
49WX_DECLARE_TYPE_POD(unsigned char)
50WX_DECLARE_TYPE_POD(signed char)
51WX_DECLARE_TYPE_POD(unsigned int)
52WX_DECLARE_TYPE_POD(signed int)
53WX_DECLARE_TYPE_POD(unsigned short int)
54WX_DECLARE_TYPE_POD(signed short int)
55WX_DECLARE_TYPE_POD(signed long int)
56WX_DECLARE_TYPE_POD(unsigned long int)
57WX_DECLARE_TYPE_POD(float)
58WX_DECLARE_TYPE_POD(double)
59WX_DECLARE_TYPE_POD(long double)
60#if wxWCHAR_T_IS_REAL_TYPE
61WX_DECLARE_TYPE_POD(wchar_t)
62#endif
63#ifdef wxLongLong_t
64WX_DECLARE_TYPE_POD(wxLongLong_t)
65WX_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:
74template<typename T>
75struct wxIsPod<T*>
76{
77 static const bool value = true;
78};
79
80template<typename T>
81struct wxIsPod<const T*>
82{
83 static const bool value = true;
84};
85
86#endif // !VC++ < 7
87
88#endif // _WX_META_POD_H_