1 // Boost.Units - A C++ library for zero-overhead dimensional analysis and
2 // unit/quantity manipulation and conversion
4 // Copyright (C) 2003-2008 Matthias Christian Schabel
5 // Copyright (C) 2008 Steven Watanabe
7 // Distributed under the Boost Software License, Version 1.0. (See
8 // accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_UNITS_SCALED_BASE_UNIT_HPP_INCLUDED
12 #define BOOST_UNITS_SCALED_BASE_UNIT_HPP_INCLUDED
16 #include <boost/mpl/bool.hpp>
17 #include <boost/mpl/less.hpp>
18 #include <boost/type_traits/is_same.hpp>
20 #include <boost/units/config.hpp>
21 #include <boost/units/dimension.hpp>
22 #include <boost/units/static_rational.hpp>
23 #include <boost/units/units_fwd.hpp>
30 struct heterogeneous_system;
32 template<class T, class D, class Scale>
33 struct heterogeneous_system_impl;
35 template<class T, class E>
36 struct heterogeneous_system_dim;
39 struct base_unit_info;
42 struct scaled_base_unit_tag {};
44 template<class S, class Scale>
45 struct scaled_base_unit
48 typedef void boost_units_is_base_unit_type;
49 typedef scaled_base_unit type;
50 typedef scaled_base_unit_tag tag;
51 typedef S system_type;
52 typedef Scale scale_type;
53 typedef typename S::dimension_type dimension_type;
55 #ifdef BOOST_UNITS_DOXYGEN
57 typedef detail::unspecified unit_type;
64 heterogeneous_system_impl<
66 heterogeneous_system_dim<scaled_base_unit,static_rational<1> >,
77 static std::string symbol()
79 return(Scale::symbol() + base_unit_info<S>::symbol());
81 static std::string name()
83 return(Scale::name() + base_unit_info<S>::name());
91 #if BOOST_UNITS_HAS_BOOST_TYPEOF
93 #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
95 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::scaled_base_unit, (class)(class))
101 #ifndef BOOST_UNITS_DOXYGEN
107 struct less_impl<boost::units::scaled_base_unit_tag, Tag>
109 template<class T0, class T1>
110 struct apply : mpl::bool_<
111 mpl::less<typename T0::system_type, T1>::value ||
112 (boost::is_same<typename T0::system_type, T1>::value && ((T0::scale_type::exponent::Numerator) < 0)) > {};
117 struct less_impl<Tag, boost::units::scaled_base_unit_tag>
119 template<class T0, class T1>
120 struct apply : mpl::bool_<
121 mpl::less<T0, typename T1::system_type>::value ||
122 (boost::is_same<T0, typename T1::system_type>::value && ((T1::scale_type::exponent::Numerator) > 0)) > {};
127 struct less_impl<boost::units::scaled_base_unit_tag, boost::units::scaled_base_unit_tag>
129 template<class T0, class T1>
130 struct apply : mpl::bool_<
131 mpl::less<typename T0::system_type, typename T1::system_type>::value ||
132 ((boost::is_same<typename T0::system_type, typename T1::system_type>::value) &&
133 ((T0::scale_type::base) < (T1::scale_type::base) ||
134 ((T0::scale_type::base) == (T1::scale_type::base) &&
135 mpl::less<typename T0::scale_type::exponent, typename T1::scale_type::exponent>::value))) > {};