Chris@16: // (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 Chris@16: // Use, modification, and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (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 library home page at http://www.boost.org/libs/numeric/conversion Chris@16: // Chris@16: // Contact the author at: fernando_cacciola@hotmail.com Chris@16: // Chris@16: #ifndef BOOST_NUMERIC_CONVERSION_DETAIL_META_FLC_12NOV2002_HPP Chris@16: #define BOOST_NUMERIC_CONVERSION_DETAIL_META_FLC_12NOV2002_HPP Chris@16: Chris@16: #include "boost/type_traits/remove_cv.hpp" Chris@16: Chris@16: #include "boost/mpl/if.hpp" Chris@16: #include "boost/mpl/eval_if.hpp" Chris@16: #include "boost/mpl/equal_to.hpp" Chris@16: #include "boost/mpl/not.hpp" Chris@16: #include "boost/mpl/and.hpp" Chris@16: #include "boost/mpl/bool.hpp" Chris@16: #include "boost/mpl/identity.hpp" Chris@16: Chris@16: namespace boost { namespace numeric { namespace convdetail Chris@16: { Chris@16: template< class T1, class T2> Chris@16: struct equal_to Chris@16: { Chris@16: #if !defined(__BORLANDC__) Chris@16: Chris@16: enum { x = ( BOOST_MPL_AUX_VALUE_WKND(T1)::value == BOOST_MPL_AUX_VALUE_WKND(T2)::value ) }; Chris@16: Chris@16: BOOST_STATIC_CONSTANT(bool, value = x); Chris@16: Chris@16: typedef mpl::bool_ type; Chris@16: Chris@16: #else Chris@16: Chris@16: BOOST_STATIC_CONSTANT(bool, value = ( Chris@16: BOOST_MPL_AUX_VALUE_WKND(T1)::value Chris@16: == BOOST_MPL_AUX_VALUE_WKND(T2)::value Chris@16: )); Chris@16: Chris@16: typedef mpl::bool_<( Chris@16: BOOST_MPL_AUX_VALUE_WKND(T1)::value Chris@16: == BOOST_MPL_AUX_VALUE_WKND(T2)::value Chris@16: )> type; Chris@16: #endif Chris@16: }; Chris@16: Chris@16: // Metafunction: Chris@16: // Chris@16: // ct_switch4::type Chris@16: // Chris@16: // {Value,Case(X)Val} are Integral Constants (such as: mpl::int_<>) Chris@16: // {Case(X)Type,DefaultType} are arbitrary types. (not metafunctions) Chris@16: // Chris@16: // Returns Case(X)Type if Val==Case(X)Val; DefaultType otherwise. Chris@16: // Chris@16: template Chris@16: struct ct_switch4 Chris@16: { Chris@16: typedef mpl::identity Case0TypeQ ; Chris@16: typedef mpl::identity Case1TypeQ ; Chris@16: Chris@16: typedef equal_to is_case0 ; Chris@16: typedef equal_to is_case1 ; Chris@16: typedef equal_to is_case2 ; Chris@16: Chris@16: typedef mpl::if_ choose_2_3Q ; Chris@16: typedef mpl::eval_if choose_1_2_3Q ; Chris@16: Chris@16: typedef typename Chris@16: mpl::eval_if::type Chris@16: type ; Chris@16: } ; Chris@16: Chris@16: Chris@16: Chris@16: Chris@16: // Metafunction: Chris@16: // Chris@16: // for_both::type Chris@16: // Chris@16: // {exp0,expr1} are Boolean Integral Constants Chris@16: // {TT,TF,FT,FF} are aribtrary types. (not metafunctions) Chris@16: // Chris@16: // According to the combined boolean value of 'expr0 && expr1', selects the corresponding type. Chris@16: // Chris@16: template Chris@16: struct for_both Chris@16: { Chris@16: typedef mpl::identity TF_Q ; Chris@16: typedef mpl::identity TT_Q ; Chris@16: Chris@16: typedef typename mpl::not_::type not_expr0 ; Chris@16: typedef typename mpl::not_::type not_expr1 ; Chris@16: Chris@16: typedef typename mpl::and_::type caseTT ; Chris@16: typedef typename mpl::and_::type caseTF ; Chris@16: typedef typename mpl::and_::type caseFT ; Chris@16: Chris@16: typedef mpl::if_ choose_FT_FF_Q ; Chris@16: typedef mpl::eval_if choose_TF_FT_FF_Q ; Chris@16: Chris@16: typedef typename mpl::eval_if::type type ; Chris@16: } ; Chris@16: Chris@16: } } } // namespace boost::numeric::convdetail Chris@16: Chris@16: #endif Chris@16: Chris@16: