Chris@16: Chris@16: #ifndef BOOST_MPL_IF_HPP_INCLUDED Chris@16: #define BOOST_MPL_IF_HPP_INCLUDED Chris@16: Chris@16: // Copyright Aleksey Gurtovoy 2000-2004 Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/mpl for documentation. Chris@16: Chris@101: // $Id$ Chris@101: // $Date$ Chris@101: // $Revision$ Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace mpl { Chris@16: Chris@16: #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) Chris@16: Chris@16: template< Chris@16: bool C Chris@16: , typename T1 Chris@16: , typename T2 Chris@16: > Chris@16: struct if_c Chris@16: { Chris@16: typedef T1 type; Chris@16: }; Chris@16: Chris@16: template< Chris@16: typename T1 Chris@16: , typename T2 Chris@16: > Chris@16: struct if_c Chris@16: { Chris@16: typedef T2 type; Chris@16: }; Chris@16: Chris@16: // agurt, 05/sep/04: nondescriptive parameter names for the sake of DigitalMars Chris@16: // (and possibly MWCW < 8.0); see http://article.gmane.org/gmane.comp.lib.boost.devel/108959 Chris@16: template< Chris@16: typename BOOST_MPL_AUX_NA_PARAM(T1) Chris@16: , typename BOOST_MPL_AUX_NA_PARAM(T2) Chris@16: , typename BOOST_MPL_AUX_NA_PARAM(T3) Chris@16: > Chris@16: struct if_ Chris@16: { Chris@16: private: Chris@16: // agurt, 02/jan/03: two-step 'type' definition for the sake of aCC Chris@16: typedef if_c< Chris@16: #if defined(BOOST_MPL_CFG_BCC_INTEGRAL_CONSTANTS) Chris@16: BOOST_MPL_AUX_VALUE_WKND(T1)::value Chris@16: #else Chris@16: BOOST_MPL_AUX_STATIC_CAST(bool, BOOST_MPL_AUX_VALUE_WKND(T1)::value) Chris@16: #endif Chris@16: , T2 Chris@16: , T3 Chris@16: > almost_type_; Chris@16: Chris@16: public: Chris@16: typedef typename almost_type_::type type; Chris@16: Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(T1,T2,T3)) Chris@16: }; Chris@16: Chris@16: #else Chris@16: Chris@16: // no partial class template specialization Chris@16: Chris@16: namespace aux { Chris@16: Chris@16: template< bool C > Chris@16: struct if_impl Chris@16: { Chris@16: template< typename T1, typename T2 > struct result_ Chris@16: { Chris@16: typedef T1 type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct if_impl Chris@16: { Chris@16: template< typename T1, typename T2 > struct result_ Chris@16: { Chris@16: typedef T2 type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: } // namespace aux Chris@16: Chris@16: template< Chris@16: bool C_ Chris@16: , typename T1 Chris@16: , typename T2 Chris@16: > Chris@16: struct if_c Chris@16: { Chris@16: typedef typename aux::if_impl< C_ > Chris@16: ::template result_::type type; Chris@16: }; Chris@16: Chris@16: // (almost) copy & paste in order to save one more Chris@16: // recursively nested template instantiation to user Chris@16: template< Chris@16: typename BOOST_MPL_AUX_NA_PARAM(C_) Chris@16: , typename BOOST_MPL_AUX_NA_PARAM(T1) Chris@16: , typename BOOST_MPL_AUX_NA_PARAM(T2) Chris@16: > Chris@16: struct if_ Chris@16: { Chris@16: enum { msvc_wknd_ = BOOST_MPL_AUX_MSVC_VALUE_WKND(C_)::value }; Chris@16: Chris@16: typedef typename aux::if_impl< BOOST_MPL_AUX_STATIC_CAST(bool, msvc_wknd_) > Chris@16: ::template result_::type type; Chris@16: Chris@16: BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C_,T1,T2)) Chris@16: }; Chris@16: Chris@16: #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Chris@16: Chris@16: BOOST_MPL_AUX_NA_SPEC(3, if_) Chris@16: Chris@16: }} Chris@16: Chris@16: #endif // BOOST_MPL_IF_HPP_INCLUDED