comparison DEPENDENCIES/generic/include/boost/units/scaled_base_unit.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 // Boost.Units - A C++ library for zero-overhead dimensional analysis and
2 // unit/quantity manipulation and conversion
3 //
4 // Copyright (C) 2003-2008 Matthias Christian Schabel
5 // Copyright (C) 2008 Steven Watanabe
6 //
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)
10
11 #ifndef BOOST_UNITS_SCALED_BASE_UNIT_HPP_INCLUDED
12 #define BOOST_UNITS_SCALED_BASE_UNIT_HPP_INCLUDED
13
14 #include <string>
15
16 #include <boost/mpl/bool.hpp>
17 #include <boost/mpl/less.hpp>
18 #include <boost/type_traits/is_same.hpp>
19 #include <boost/type_traits/detail/ice_and.hpp>
20 #include <boost/type_traits/detail/ice_or.hpp>
21
22 #include <boost/units/config.hpp>
23 #include <boost/units/dimension.hpp>
24 #include <boost/units/static_rational.hpp>
25 #include <boost/units/units_fwd.hpp>
26
27 namespace boost {
28
29 namespace units {
30
31 template<class T>
32 struct heterogeneous_system;
33
34 template<class T, class D, class Scale>
35 struct heterogeneous_system_impl;
36
37 template<class T, class E>
38 struct heterogeneous_system_dim;
39
40 template<class T>
41 struct base_unit_info;
42
43 /// INTERNAL ONLY
44 struct scaled_base_unit_tag {};
45
46 template<class S, class Scale>
47 struct scaled_base_unit
48 {
49 /// INTERNAL ONLY
50 typedef void boost_units_is_base_unit_type;
51 typedef scaled_base_unit type;
52 typedef scaled_base_unit_tag tag;
53 typedef S system_type;
54 typedef Scale scale_type;
55 typedef typename S::dimension_type dimension_type;
56
57 #ifdef BOOST_UNITS_DOXYGEN
58
59 typedef detail::unspecified unit_type;
60
61 #else
62
63 typedef unit<
64 dimension_type,
65 heterogeneous_system<
66 heterogeneous_system_impl<
67 list<
68 heterogeneous_system_dim<scaled_base_unit,static_rational<1> >,
69 dimensionless_type
70 >,
71 dimension_type,
72 dimensionless_type
73 >
74 >
75 > unit_type;
76
77 #endif
78
79 static std::string symbol()
80 {
81 return(Scale::symbol() + base_unit_info<S>::symbol());
82 }
83 static std::string name()
84 {
85 return(Scale::name() + base_unit_info<S>::name());
86 }
87 };
88
89 } // namespace units
90
91 } // namespace boost
92
93 #if BOOST_UNITS_HAS_BOOST_TYPEOF
94
95 #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
96
97 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::scaled_base_unit, (class)(class))
98
99 #endif
100
101 namespace boost {
102
103 #ifndef BOOST_UNITS_DOXYGEN
104
105 namespace mpl {
106
107 /// INTERNAL ONLY
108 template<class Tag>
109 struct less_impl<boost::units::scaled_base_unit_tag, Tag>
110 {
111 template<class T0, class T1>
112 struct apply : mpl::bool_<
113 boost::type_traits::ice_or<(mpl::less<typename T0::system_type, T1>::value),
114 (boost::type_traits::ice_and<boost::is_same<typename T0::system_type, T1>::value, (T0::scale_type::exponent::Numerator) < 0>::value)>::value> {};
115 };
116
117 /// INTERNAL ONLY
118 template<class Tag>
119 struct less_impl<Tag, boost::units::scaled_base_unit_tag>
120 {
121 template<class T0, class T1>
122 struct apply : mpl::bool_<
123 boost::type_traits::ice_or<(mpl::less<T0, typename T1::system_type>::value),
124 boost::type_traits::ice_and<(boost::is_same<T0, typename T1::system_type>::value), ((T1::scale_type::exponent::Numerator) > 0)>::value>::value> {};
125 };
126
127 /// INTERNAL ONLY
128 template<>
129 struct less_impl<boost::units::scaled_base_unit_tag, boost::units::scaled_base_unit_tag>
130 {
131 template<class T0, class T1>
132 struct apply : mpl::bool_<
133 boost::type_traits::ice_or<(mpl::less<typename T0::system_type, typename T1::system_type>::value),
134 boost::type_traits::ice_and<(boost::is_same<typename T0::system_type, typename T1::system_type>::value),
135 boost::type_traits::ice_or<((T0::scale_type::base) < (T1::scale_type::base)),
136 boost::type_traits::ice_and<((T0::scale_type::base) == (T1::scale_type::base)),
137 (mpl::less<typename T0::scale_type::exponent,typename T1::scale_type::exponent>::value)>::value>::value>::value>::value> {};
138 };
139
140 } // namespace mpl
141
142 #endif
143
144 } // namespace boost
145
146 #endif