Chris@16: // Boost.Units - A C++ library for zero-overhead dimensional analysis and Chris@16: // unit/quantity manipulation and conversion Chris@16: // Chris@16: // Copyright (C) 2003-2008 Matthias Christian Schabel Chris@16: // Copyright (C) 2007-2008 Steven Watanabe Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_UNITS_DETAIL_UNSCALE_HPP_INCLUDED Chris@16: #define BOOST_UNITS_DETAIL_UNSCALE_HPP_INCLUDED Chris@16: Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: namespace units { Chris@16: Chris@16: template Chris@16: struct heterogeneous_system; Chris@16: Chris@16: template Chris@16: struct heterogeneous_system_impl; Chris@16: Chris@16: template Chris@16: struct heterogeneous_system_dim; Chris@16: Chris@16: template Chris@16: struct scaled_base_unit; Chris@16: Chris@16: /// removes all scaling from a unit or a base unit. Chris@16: template Chris@16: struct unscale Chris@16: { Chris@16: #ifndef BOOST_UNITS_DOXYGEN Chris@16: typedef T type; Chris@16: #else Chris@16: typedef detail::unspecified type; Chris@16: #endif Chris@16: }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template Chris@16: struct unscale > Chris@16: { Chris@16: typedef typename unscale::type type; Chris@16: }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template Chris@16: struct unscale > Chris@16: { Chris@16: typedef unit::type> type; Chris@16: }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template Chris@16: struct scale_list_dim; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template Chris@16: struct get_scale_list Chris@16: { Chris@16: typedef dimensionless_type type; Chris@16: }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template Chris@16: struct get_scale_list > Chris@16: { Chris@16: typedef typename mpl::times, dimensionless_type>, typename get_scale_list::type>::type type; Chris@16: }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template Chris@16: struct get_scale_list > Chris@16: { Chris@16: typedef typename get_scale_list::type type; Chris@16: }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: struct scale_dim_tag {}; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template Chris@16: struct scale_list_dim : Scale Chris@16: { Chris@16: typedef scale_dim_tag tag; Chris@16: typedef scale_list_dim type; Chris@16: }; Chris@16: Chris@16: } // namespace units Chris@16: Chris@16: #ifndef BOOST_UNITS_DOXYGEN Chris@16: Chris@16: namespace mpl { Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template<> Chris@16: struct less_impl Chris@16: { Chris@16: template Chris@16: struct apply : mpl::bool_<((T0::base) < (T1::base))> {}; Chris@16: }; Chris@16: Chris@16: } Chris@16: Chris@16: #endif Chris@16: Chris@16: namespace units { Chris@16: Chris@16: namespace detail { Chris@16: Chris@16: template Chris@16: struct is_empty_dim > : mpl::false_ {}; Chris@16: Chris@16: template Chris@16: struct is_empty_dim > > > : mpl::true_ {}; Chris@16: Chris@16: template Chris@16: struct eval_scale_list_impl Chris@16: { Chris@16: template Chris@16: struct apply Chris@16: { Chris@16: typedef typename eval_scale_list_impl::template apply next_iteration; Chris@16: typedef typename multiply_typeof_helper::type type; Chris@16: static type value() Chris@16: { Chris@16: return(next_iteration::value() * Begin::item::value()); Chris@16: } Chris@16: }; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct eval_scale_list_impl<0> Chris@16: { Chris@16: template Chris@16: struct apply Chris@16: { Chris@16: typedef one type; Chris@16: static one value() Chris@16: { Chris@16: one result; Chris@16: return(result); Chris@16: } Chris@16: }; Chris@16: }; Chris@16: Chris@16: } Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template Chris@16: struct eval_scale_list : detail::eval_scale_list_impl::template apply {}; Chris@16: Chris@16: } // namespace units Chris@16: Chris@16: #ifndef BOOST_UNITS_DOXYGEN Chris@16: Chris@16: namespace mpl { Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template<> Chris@16: struct plus_impl Chris@16: { Chris@16: template Chris@16: struct apply Chris@16: { Chris@16: typedef boost::units::scale_list_dim< Chris@16: boost::units::scale< Chris@16: (T0::base), Chris@16: typename mpl::plus::type Chris@16: > Chris@16: > type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template<> Chris@16: struct negate_impl Chris@16: { Chris@16: template Chris@16: struct apply Chris@16: { Chris@16: typedef boost::units::scale_list_dim< Chris@16: boost::units::scale< Chris@16: (T0::base), Chris@16: typename mpl::negate::type Chris@16: > Chris@16: > type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: /// INTERNAL ONLY Chris@16: template<> Chris@16: struct times_impl Chris@16: { Chris@16: template Chris@16: struct apply Chris@16: { Chris@16: typedef boost::units::scale_list_dim< Chris@16: boost::units::scale< Chris@16: (T0::base), Chris@16: typename mpl::times::type Chris@16: > Chris@16: > type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: } // namespace mpl Chris@16: Chris@16: #endif Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #endif