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