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_CONVERSION_TRAITS_FLC_12NOV2002_HPP Chris@16: #define BOOST_NUMERIC_CONVERSION_DETAIL_CONVERSION_TRAITS_FLC_12NOV2002_HPP Chris@16: Chris@16: #include "boost/type_traits/is_arithmetic.hpp" Chris@16: #include "boost/type_traits/is_same.hpp" Chris@16: #include "boost/type_traits/remove_cv.hpp" Chris@16: Chris@16: #include "boost/numeric/conversion/detail/meta.hpp" Chris@16: #include "boost/numeric/conversion/detail/int_float_mixture.hpp" Chris@16: #include "boost/numeric/conversion/detail/sign_mixture.hpp" Chris@16: #include "boost/numeric/conversion/detail/udt_builtin_mixture.hpp" Chris@16: #include "boost/numeric/conversion/detail/is_subranged.hpp" Chris@16: Chris@16: namespace boost { namespace numeric { namespace convdetail Chris@16: { Chris@16: //------------------------------------------------------------------- Chris@16: // Implementation of the Conversion Traits for T != S Chris@16: // Chris@16: // This is a VISIBLE base class of the user-level conversion_traits<> class. Chris@16: //------------------------------------------------------------------- Chris@16: template Chris@16: struct non_trivial_traits_impl Chris@16: { Chris@16: typedef typename get_int_float_mixture ::type int_float_mixture ; Chris@16: typedef typename get_sign_mixture ::type sign_mixture ; Chris@16: typedef typename get_udt_builtin_mixture ::type udt_builtin_mixture ; Chris@16: Chris@16: typedef typename get_is_subranged::type subranged ; Chris@16: Chris@16: typedef mpl::false_ trivial ; Chris@16: Chris@16: typedef T target_type ; Chris@16: typedef S source_type ; Chris@16: typedef T result_type ; Chris@16: Chris@16: typedef typename mpl::if_< is_arithmetic, S, S const&>::type argument_type ; Chris@16: Chris@16: typedef typename mpl::if_::type supertype ; Chris@16: typedef typename mpl::if_::type subtype ; Chris@16: } ; Chris@16: Chris@16: //------------------------------------------------------------------- Chris@16: // Implementation of the Conversion Traits for T == S Chris@16: // Chris@16: // This is a VISIBLE base class of the user-level conversion_traits<> class. Chris@16: //------------------------------------------------------------------- Chris@16: template Chris@16: struct trivial_traits_impl Chris@16: { Chris@16: typedef typename get_int_float_mixture ::type int_float_mixture ; Chris@16: typedef typename get_sign_mixture ::type sign_mixture ; Chris@16: typedef typename get_udt_builtin_mixture::type udt_builtin_mixture ; Chris@16: Chris@16: typedef mpl::false_ subranged ; Chris@16: typedef mpl::true_ trivial ; Chris@16: Chris@16: typedef N target_type ; Chris@16: typedef N source_type ; Chris@16: typedef N const& result_type ; Chris@16: typedef N const& argument_type ; Chris@16: Chris@16: typedef N supertype ; Chris@16: typedef N subtype ; Chris@16: Chris@16: } ; Chris@16: Chris@16: //------------------------------------------------------------------- Chris@16: // Top level implementation selector. Chris@16: //------------------------------------------------------------------- Chris@16: template Chris@16: struct get_conversion_traits Chris@16: { Chris@16: typedef typename remove_cv::type target_type ; Chris@16: typedef typename remove_cv::type source_type ; Chris@16: Chris@16: typedef typename is_same::type is_trivial ; Chris@16: Chris@16: typedef trivial_traits_impl trivial_imp ; Chris@16: typedef non_trivial_traits_impl non_trivial_imp ; Chris@16: Chris@16: typedef typename mpl::if_::type type ; Chris@16: } ; Chris@16: Chris@16: } } } // namespace boost::numeric::convdetail Chris@16: Chris@16: #endif Chris@16: Chris@16: