]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/meta/if.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: declares wxIf<> metaprogramming construct
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2008 Vaclav Slavik
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_META_IF_H_
12 #define _WX_META_IF_H_
16 // NB: This code is intentionally written without partial templates
17 // specialization, because some older compilers (notably VC6) don't
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)
33 template<typename TTrue
, typename TFalse
> struct Result
35 // intentionally don't define value here, this shouldn't be actually
36 // used, it's here just to work around a compiler bug
42 // specialization for true:
46 template<typename TTrue
, typename TFalse
> struct Result
52 // specialization for false:
54 struct wxIfImpl
<false>
56 template<typename TTrue
, typename TFalse
> struct Result
62 } // namespace wxPrivate
64 // wxIf<> template defines nested type "value" which is the same as
65 // TTrue if the condition Cond (boolean compile-time constant) was met and
66 // TFalse if it wasn't.
68 // See wxVector<T> in vector.h for usage example
69 template<bool Cond
, typename TTrue
, typename TFalse
>
70 struct wxIf
: wxPrivate::wxIfImpl
<Cond
>::template Result
<TTrue
, TFalse
>
74 #endif // _WX_META_IF_H_