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