#ifndef BOOST_MPL_IF_HPP_INCLUDED #define BOOST_MPL_IF_HPP_INCLUDED // + file: boost/mpl/if.hpp // + last modified: 17/sep/03 // Copyright (c) 2000-03 Boost.org // // Permission to use, copy, modify, distribute and sell this software // and its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appears in all copies and // that both the copyright notice and this permission notice appear in // supporting documentation. No representations are made about the // suitability of this software for any purpose. It is provided "as is" // without express or implied warranty. // // See http://www.boost.org/libs/mpl for documentation. #include "boost/mpl/void.hpp" #include "boost/mpl/aux_/value_wknd.hpp" #include "boost/mpl/aux_/static_cast.hpp" #include "boost/mpl/aux_/void_spec.hpp" #include "boost/mpl/aux_/lambda_support.hpp" #include "boost/mpl/aux_/config/workaround.hpp" #include "boost/config.hpp" #if !defined(BOOST_MPL_NO_FULL_LAMBDA_SUPPORT) # include "boost/mpl/arg_fwd.hpp" #endif namespace boost { namespace mpl { #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) BOOST_MPL_AUX_AGLORITHM_NAMESPACE_BEGIN template< bool C , typename T1 , typename T2 > struct if_c { typedef T1 type; }; template< typename T1 , typename T2 > struct if_c { typedef T2 type; }; template< typename BOOST_MPL_AUX_VOID_SPEC_PARAM(C) , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T1) , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T2) > struct if_ { private: // agurt, 02/jan/03: two-step 'type' definition for the sake of aCC typedef if_c< #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561)) BOOST_MPL_AUX_VALUE_WKND(C)::value #else BOOST_MPL_AUX_STATIC_CAST(bool, BOOST_MPL_AUX_VALUE_WKND(C)::value) #endif , T1 , T2 > almost_type_; public: typedef typename almost_type_::type type; BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C,T1,T2)) }; #else // no partial class template specialization namespace aux { template< bool C > struct if_impl { template< typename T1, typename T2 > struct result_ { typedef T1 type; }; }; template<> struct if_impl { template< typename T1, typename T2 > struct result_ { typedef T2 type; }; }; } // namespace aux template< bool C_ , typename T1 , typename T2 > struct if_c { typedef typename aux::if_impl< C_ > ::template result_::type type; }; // (almost) copy & paste in order to save one more // recursively nested template instantiation to user template< typename BOOST_MPL_AUX_VOID_SPEC_PARAM(C_) , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T1) , typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T2) > struct if_ { enum { msvc70_wknd_ = C_::value }; typedef typename aux::if_impl< BOOST_MPL_AUX_STATIC_CAST(bool, msvc70_wknd_) > ::template result_::type type; BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C_,T1,T2)) }; #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION BOOST_MPL_AUX_AGLORITHM_NAMESPACE_END BOOST_MPL_AUX_ALGORITHM_VOID_SPEC(3, if_) #if !defined(BOOST_MPL_NO_FULL_LAMBDA_SUPPORT) // Aleksey, check it out: lazy if_ evaluation in lambdas! // I think this doesn't handle the case of // // _1, bar<_2>, baz<_2> > // // (or however it is that you express that... when the ordinary bind3 // computes the function based on the actual arguments). That leads me // to think that some kind of true currying might be a better // approach, e.g.: // // // boost::mpl::bind3< // boost::mpl::quote3 // , boost::mpl::bind1, boost::mpl::arg<1> > // , boost::mpl::arg<1> // , boost::mpl::bind1, boost::mpl::arg<1> > // >::apply<...> // // becomes: // // boost::mpl::bind< // boost::mpl::quote3 // >::bind< // , boost::mpl::bind1, // boost::mpl::arg<1> > // >::bind< // boost::mpl::arg<1> // >::bind< // boost::mpl::bind1, boost::mpl::arg<1> > // >::apply<...> // // so that after the 2nd bind we have a different function depending // on the result of is_reference. template struct bind3; template