]> git.saurik.com Git - wxWidgets.git/blame - include/wx/meta/if.h
Remove unnecessary IsRadioButton().
[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
14// NB: This code is intentionally written without partial templates
15// specialization, because some older compilers (notably VC6) don't
16// support it.
17
18namespace wxPrivate
19{
20
21template<bool Cond> struct wxIfImpl {};
22
23// specialization for true:
24template<>
25struct wxIfImpl<true>
26{
27 template<typename TTrue, typename TFalse> struct Result
28 {
29 typedef TTrue value;
30 };
31};
32
33// specialization for false:
34template<>
35struct wxIfImpl<false>
36{
37 template<typename TTrue, typename TFalse> struct Result
38 {
39 typedef TFalse value;
40 };
41};
42
43} // namespace wxPrivate
44
45// wxIf<> template defines nested type "value" which is the same as
46// TTrue if the condition Cond (boolean compile-time constant) was met and
47// TFalse if it wasn't.
48//
49// See wxVector<T> in vector.h for usage example
50template<bool Cond, typename TTrue, typename TFalse>
51struct wxIf
52{
53 typedef typename wxPrivate::wxIfImpl<Cond>
54 ::template Result<TTrue,TFalse>::value
55 value;
56};
57
58#endif // _WX_META_IF_H_