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_CONVERSION_TRAITS_FLC_12NOV2002_HPP
0011 #define BOOST_NUMERIC_CONVERSION_DETAIL_CONVERSION_TRAITS_FLC_12NOV2002_HPP
0012 
0013 #include "boost/type_traits/is_arithmetic.hpp"
0014 #include "boost/type_traits/is_same.hpp"
0015 #include "boost/type_traits/remove_cv.hpp"
0016 
0017 #include "boost/numeric/conversion/detail/meta.hpp"
0018 #include "boost/numeric/conversion/detail/int_float_mixture.hpp"
0019 #include "boost/numeric/conversion/detail/sign_mixture.hpp"
0020 #include "boost/numeric/conversion/detail/udt_builtin_mixture.hpp"
0021 #include "boost/numeric/conversion/detail/is_subranged.hpp"
0022 
0023 namespace boost { namespace numeric { namespace convdetail
0024 {
0025   //-------------------------------------------------------------------
0026   // Implementation of the Conversion Traits for T != S
0027   //
0028   // This is a VISIBLE base class of the user-level conversion_traits<> class.
0029   //-------------------------------------------------------------------
0030   template<class T,class S>
0031   struct non_trivial_traits_impl
0032   {
0033     typedef typename get_int_float_mixture   <T,S>::type int_float_mixture ;
0034     typedef typename get_sign_mixture        <T,S>::type sign_mixture ;
0035     typedef typename get_udt_builtin_mixture <T,S>::type udt_builtin_mixture ;
0036 
0037     typedef typename get_is_subranged<T,S>::type subranged ;
0038 
0039     typedef mpl::false_ trivial ;
0040 
0041     typedef T target_type ;
0042     typedef S source_type ;
0043     typedef T result_type ;
0044 
0045     typedef typename mpl::if_< is_arithmetic<S>, S, S const&>::type argument_type ;
0046 
0047     typedef typename mpl::if_<subranged,S,T>::type supertype ;
0048     typedef typename mpl::if_<subranged,T,S>::type subtype   ;
0049   } ;
0050 
0051   //-------------------------------------------------------------------
0052   // Implementation of the Conversion Traits for T == S
0053   //
0054   // This is a VISIBLE base class of the user-level conversion_traits<> class.
0055   //-------------------------------------------------------------------
0056   template<class N>
0057   struct trivial_traits_impl
0058   {
0059     typedef typename get_int_float_mixture  <N,N>::type int_float_mixture ;
0060     typedef typename get_sign_mixture       <N,N>::type sign_mixture ;
0061     typedef typename get_udt_builtin_mixture<N,N>::type udt_builtin_mixture ;
0062 
0063     typedef mpl::false_ subranged ;
0064     typedef mpl::true_  trivial ;
0065 
0066     typedef N        target_type ;
0067     typedef N        source_type ;
0068     typedef N const& result_type ;
0069     typedef N const& argument_type ;
0070 
0071     typedef N supertype ;
0072     typedef N subtype  ;
0073 
0074   } ;
0075 
0076   //-------------------------------------------------------------------
0077   // Top level implementation selector.
0078   //-------------------------------------------------------------------
0079   template<class T, class S>
0080   struct get_conversion_traits
0081   {
0082     typedef typename remove_cv<T>::type target_type ;
0083     typedef typename remove_cv<S>::type source_type ;
0084 
0085     typedef typename is_same<target_type,source_type>::type is_trivial ;
0086 
0087     typedef trivial_traits_impl    <target_type>             trivial_imp ;
0088     typedef non_trivial_traits_impl<target_type,source_type> non_trivial_imp ;
0089 
0090     typedef typename mpl::if_<is_trivial,trivial_imp,non_trivial_imp>::type type ;
0091   } ;
0092 
0093 } } } // namespace boost::numeric::convdetail
0094 
0095 #endif
0096 
0097