2 #ifndef BOOST_MPL_IF_HPP_INCLUDED
3 #define BOOST_MPL_IF_HPP_INCLUDED
5 // + file: boost/mpl/if.hpp
6 // + last modified: 10/mar/03
8 // Copyright (c) 2000-03 Boost.org
10 // Permission to use, copy, modify, distribute and sell this software
11 // and its documentation for any purpose is hereby granted without fee,
12 // provided that the above copyright notice appears in all copies and
13 // that both the copyright notice and this permission notice appear in
14 // supporting documentation. No representations are made about the
15 // suitability of this software for any purpose. It is provided "as is"
16 // without express or implied warranty.
18 // See http://www.boost.org/libs/mpl for documentation.
20 #include "boost/mpl/aux_/value_wknd.hpp"
21 #include "boost/mpl/aux_/ice_cast.hpp"
22 #include "boost/mpl/aux_/void_spec.hpp"
23 #include "boost/mpl/aux_/lambda_support.hpp"
24 #include "boost/mpl/aux_/config/workaround.hpp"
25 #include "boost/config.hpp"
30 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
46 struct if_c<false,T1,T2>
52 typename BOOST_MPL_AUX_VOID_SPEC_PARAM(C)
53 , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T1)
54 , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T2)
59 // agurt, 02/jan/03: two-step 'type' definition for the sake of aCC
61 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561))
62 BOOST_MPL_AUX_VALUE_WKND(C)::value
64 BOOST_MPL_AUX_ICE_CAST(bool, BOOST_MPL_AUX_VALUE_WKND(C)::value)
71 typedef typename almost_type_::type type;
73 BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C,T1,T2))
76 #elif defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
78 // MSVC6.5-specific version
88 template<bool> struct answer { typedef T1 type; };
89 template<> struct answer<false> { typedef T2 type; };
92 typedef typename answer< C_ >::type type;
95 // (almost) copy & paste in order to save one more
96 // recursively nested template instantiation to user
105 template<bool> struct answer { typedef T1 type; };
106 template<> struct answer<false> { typedef T2 type; };
108 // agurt, 17/sep/02: in some situations MSVC 7.0 doesn't
109 // handle 'answer<C::value>' expression very well
110 enum { c_ = C_::value };
113 typedef typename answer< BOOST_MPL_AUX_ICE_CAST(bool, c_) >::type type;
115 BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C_,T1,T2))
120 // no partial class template specialization
127 template< typename T1, typename T2 > struct result_
134 struct if_impl<false>
136 template< typename T1, typename T2 > struct result_
151 typedef typename aux::if_impl< C >
152 ::template result_<T1,T2>::type type;
155 // (almost) copy & paste in order to save one more
156 // recursively nested template instantiation to user
158 typename BOOST_MPL_AUX_VOID_SPEC_PARAM(C)
159 , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T1)
160 , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T2)
164 typedef typename aux::if_impl< BOOST_MPL_AUX_ICE_CAST(bool, C::value) >
165 ::template result_<T1,T2>::type type;
167 BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C,T1,T2))
170 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
172 BOOST_MPL_AUX_VOID_SPEC(3, if_)
177 #endif // BOOST_MPL_IF_HPP_INCLUDED