]> git.saurik.com Git - wxWidgets.git/blame - include/wx/meta/if.h
Revert "Make wxMSW stack walking methods work with Unicode identifiers."
[wxWidgets.git] / include / wx / meta / if.h
CommitLineData
6712283c
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/meta/if.h
3// Purpose: declares wxIf<> metaprogramming construct
4// Author: Vaclav Slavik
5// Created: 2008-01-22
6712283c
VS
6// Copyright: (c) 2008 Vaclav Slavik
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_META_IF_H_
11#define _WX_META_IF_H_
12
986d59e2
VZ
13#include "wx/defs.h"
14
6712283c
VS
15// NB: This code is intentionally written without partial templates
16// specialization, because some older compilers (notably VC6) don't
17// support it.
18
19namespace wxPrivate
20{
21
986d59e2
VZ
22template <bool Cond>
23struct wxIfImpl
24
25// broken VC6 needs not just an incomplete template class declaration but a
26// "skeleton" declaration of the specialized versions below as it apparently
27// tries to look up the types in the generic template definition at some moment
28// even though it ends up by using the correct specialization in the end -- but
29// without this skeleton it doesn't recognize Result as a class at all below
30#if defined(__VISUALC__) && !wxCHECK_VISUALC_VERSION(7)
31{
c9faa9e9 32 template<typename TTrue, typename TFalse> struct Result {};
986d59e2
VZ
33}
34#endif // VC++ <= 6
35;
6712283c
VS
36
37// specialization for true:
986d59e2 38template <>
6712283c
VS
39struct wxIfImpl<true>
40{
41 template<typename TTrue, typename TFalse> struct Result
42 {
04e5392a 43 typedef TTrue value;
6712283c
VS
44 };
45};
46
47// specialization for false:
48template<>
49struct wxIfImpl<false>
50{
51 template<typename TTrue, typename TFalse> struct Result
52 {
04e5392a 53 typedef TFalse value;
6712283c
VS
54 };
55};
56
57} // namespace wxPrivate
58
03647350 59// wxIf<> template defines nested type "value" which is the same as
6712283c
VS
60// TTrue if the condition Cond (boolean compile-time constant) was met and
61// TFalse if it wasn't.
62//
63// See wxVector<T> in vector.h for usage example
64template<bool Cond, typename TTrue, typename TFalse>
e6649f2d 65struct wxIf
6712283c 66{
04e5392a
VS
67 typedef typename wxPrivate::wxIfImpl<Cond>
68 ::template Result<TTrue, TFalse>::value
69 value;
6712283c
VS
70};
71
72#endif // _WX_META_IF_H_