Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:46

0001 //  (c) Copyright Fernando Luis Cacciola Carballal 2000-2004
0002 //  Use, modification, and distribution is subject to the Boost Software
0003 //  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See library home page at http://www.boost.org/libs/numeric/conversion
0007 //
0008 // Contact the author at: fernando_cacciola@hotmail.com
0009 // 
0010 #ifndef BOOST_NUMERIC_CONVERSION_DETAIL_META_FLC_12NOV2002_HPP
0011 #define BOOST_NUMERIC_CONVERSION_DETAIL_META_FLC_12NOV2002_HPP
0012 
0013 #include "boost/type_traits/remove_cv.hpp"
0014 
0015 #include "boost/mpl/if.hpp"
0016 #include "boost/mpl/eval_if.hpp"
0017 #include "boost/mpl/equal_to.hpp"
0018 #include "boost/mpl/not.hpp"
0019 #include "boost/mpl/and.hpp"
0020 #include "boost/mpl/bool.hpp"
0021 #include "boost/mpl/identity.hpp"
0022 
0023 namespace boost { namespace numeric { namespace convdetail
0024 {
0025    template< class T1, class T2>
0026    struct equal_to
0027    {
0028    #if !defined(BOOST_BORLANDC)
0029    
0030        enum { x = ( BOOST_MPL_AUX_VALUE_WKND(T1)::value == BOOST_MPL_AUX_VALUE_WKND(T2)::value ) };
0031            
0032        BOOST_STATIC_CONSTANT(bool, value = x);
0033            
0034        typedef mpl::bool_<value> type;
0035        
0036    #else
0037    
0038        BOOST_STATIC_CONSTANT(bool, value = (
0039              BOOST_MPL_AUX_VALUE_WKND(T1)::value 
0040                == BOOST_MPL_AUX_VALUE_WKND(T2)::value
0041            ));
0042            
0043        typedef mpl::bool_<(
0044              BOOST_MPL_AUX_VALUE_WKND(T1)::value 
0045                == BOOST_MPL_AUX_VALUE_WKND(T2)::value
0046            )> type;
0047    #endif
0048    };
0049     
0050 // Metafunction:
0051   //
0052   //   ct_switch4<Value,Case0Val,Case1Val,Case2Val,Case0Type,Case1Type,Case2Type,DefaultType>::type
0053   //
0054   // {Value,Case(X)Val} are Integral Constants (such as: mpl::int_<>)
0055   // {Case(X)Type,DefaultType} are arbitrary types. (not metafunctions)
0056   //
0057   // Returns Case(X)Type if Val==Case(X)Val; DefaultType otherwise.
0058   //
0059   template<class Value,
0060            class Case0Val,
0061            class Case1Val,
0062            class Case2Val,
0063            class Case0Type,
0064            class Case1Type,
0065            class Case2Type,
0066            class DefaultType
0067           >
0068   struct ct_switch4
0069   {
0070     typedef mpl::identity<Case0Type> Case0TypeQ ;
0071     typedef mpl::identity<Case1Type> Case1TypeQ ;
0072 
0073     typedef equal_to<Value,Case0Val> is_case0 ;
0074     typedef equal_to<Value,Case1Val> is_case1 ;
0075     typedef equal_to<Value,Case2Val> is_case2 ;
0076 
0077     typedef mpl::if_<is_case2,Case2Type,DefaultType> choose_2_3Q ;
0078     typedef mpl::eval_if<is_case1,Case1TypeQ,choose_2_3Q> choose_1_2_3Q ;
0079 
0080     typedef typename
0081       mpl::eval_if<is_case0,Case0TypeQ,choose_1_2_3Q>::type
0082         type ;
0083   } ;
0084 
0085 
0086 
0087 
0088   // Metafunction:
0089   //
0090   //   for_both<expr0,expr1,TT,TF,FT,FF>::type
0091   //
0092   // {exp0,expr1} are Boolean Integral Constants
0093   // {TT,TF,FT,FF} are aribtrary types. (not metafunctions)
0094   //
0095   // According to the combined boolean value of 'expr0 && expr1', selects the corresponding type.
0096   //
0097   template<class expr0, class expr1, class TT, class TF, class FT, class FF>
0098   struct for_both
0099   {
0100     typedef mpl::identity<TF> TF_Q ;
0101     typedef mpl::identity<TT> TT_Q ;
0102 
0103     typedef typename mpl::not_<expr0>::type not_expr0 ;
0104     typedef typename mpl::not_<expr1>::type not_expr1 ;
0105 
0106     typedef typename mpl::and_<expr0,expr1>::type     caseTT ;
0107     typedef typename mpl::and_<expr0,not_expr1>::type caseTF ;
0108     typedef typename mpl::and_<not_expr0,expr1>::type caseFT ;
0109 
0110     typedef mpl::if_<caseFT,FT,FF>                    choose_FT_FF_Q ;
0111     typedef mpl::eval_if<caseTF,TF_Q,choose_FT_FF_Q> choose_TF_FT_FF_Q ;
0112 
0113     typedef typename mpl::eval_if<caseTT,TT_Q,choose_TF_FT_FF_Q>::type type ;
0114   } ;
0115 
0116 } } } // namespace boost::numeric::convdetail
0117 
0118 #endif
0119 
0120