]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/meta/if.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: declares wxIf<> metaprogramming construct
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2008 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_META_IF_H_
11 #define _WX_META_IF_H_
15 // NB: This code is intentionally written without partial templates
16 // specialization, because some older compilers (notably VC6) don't
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)
32 template<typename TTrue
, typename TFalse
> struct Result
{};
37 // specialization for true:
41 template<typename TTrue
, typename TFalse
> struct Result
47 // specialization for false:
49 struct wxIfImpl
<false>
51 template<typename TTrue
, typename TFalse
> struct Result
57 } // namespace wxPrivate
59 // wxIf<> template defines nested type "value" which is the same as
60 // TTrue if the condition Cond (boolean compile-time constant) was met and
61 // TFalse if it wasn't.
63 // See wxVector<T> in vector.h for usage example
64 template<bool Cond
, typename TTrue
, typename TFalse
>
67 typedef typename
wxPrivate::wxIfImpl
<Cond
>
68 ::template Result
<TTrue
, TFalse
>::value
72 #endif // _WX_META_IF_H_