1 //-----------------------------------------------------------------------------
2 // boost/mpl/if.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
6 // Copyright (c) 2000-02 Boost.org
8 // Permission to use, copy, modify, distribute and sell this software
9 // and its documentation for any purpose is hereby granted without fee,
10 // provided that the above copyright notice appears in all copies and
11 // that both the copyright notice and this permission notice appear in
12 // supporting documentation. No representations are made about the
13 // suitability of this software for any purpose. It is provided "as is"
14 // without express or implied warranty.
16 #ifndef BOOST_MPL_IF_HPP_INCLUDED
17 #define BOOST_MPL_IF_HPP_INCLUDED
19 #include "boost/mpl/aux_/value_wknd.hpp"
20 #include "boost/mpl/aux_/void_spec.hpp"
21 #include "boost/mpl/aux_/lambda_support.hpp"
22 #include "boost/config.hpp"
27 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
43 struct if_c<false,T1,T2>
49 typename BOOST_MPL_AUX_VOID_SPEC_PARAM(C)
50 , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T1)
51 , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T2)
55 typedef typename if_c<
56 BOOST_MPL_AUX_VALUE_WKND(C)::value
61 BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C,T1,T2))
64 #elif defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
66 // MSVC6.5-specific version
76 template<bool> struct answer { typedef T1 type; };
77 template<> struct answer<false> { typedef T2 type; };
80 typedef typename answer< C >::type type;
83 // (almost) copy & paste in order to save one more
84 // recursively nested template instantiation to user
93 template<bool> struct answer { typedef T1 type; };
94 template<> struct answer<false> { typedef T2 type; };
96 // agurt, 17/sep/02: in some situations MSVC 7.0 doesn't
97 // handle 'answer<C::value>' expression very well
98 enum { c_ = C::value };
101 typedef typename answer<c_>::type type;
106 // no partial class template specialization
113 template< typename T1, typename T2 > struct result_
120 struct if_impl<false>
122 template< typename T1, typename T2 > struct result_
137 typedef typename aux::if_impl< C >
138 ::template result_<T1,T2>::type type;
141 // (almost) copy & paste in order to save one more
142 // recursively nested template instantiation to user
144 typename BOOST_MPL_AUX_VOID_SPEC_PARAM(C)
145 , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T1)
146 , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T2)
150 typedef typename aux::if_impl< C::value >
151 ::template result_<T1,T2>::type type;
153 BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C,T1,T2))
156 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
158 BOOST_MPL_AUX_VOID_SPEC(3, if_)
163 #endif // BOOST_MPL_IF_HPP_INCLUDED