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_DERIVED_DIMENSION_HPP 12 #define BOOST_UNITS_DERIVED_DIMENSION_HPP 13 14 #include <boost/units/dim.hpp> 15 #include <boost/units/dimension.hpp> 16 #include <boost/units/static_rational.hpp> 17 #include <boost/units/units_fwd.hpp> 18 #include <boost/units/detail/dimension_list.hpp> 19 20 namespace boost { 21 22 namespace units { 23 24 /// A utility class for defining composite dimensions with integer powers. 25 template<class DT1 = dimensionless_type,long E1 = 0, 26 class DT2 = dimensionless_type,long E2 = 0, 27 class DT3 = dimensionless_type,long E3 = 0, 28 class DT4 = dimensionless_type,long E4 = 0, 29 class DT5 = dimensionless_type,long E5 = 0, 30 class DT6 = dimensionless_type,long E6 = 0, 31 class DT7 = dimensionless_type,long E7 = 0, 32 class DT8 = dimensionless_type,long E8 = 0> 33 struct derived_dimension 34 { 35 #ifdef BOOST_UNITS_DOXYGEN 36 typedef detail::unspecified type; 37 #else 38 typedef typename 39 make_dimension_list< list< dim< DT1,static_rational<E1> >, 40 list< dim< DT2,static_rational<E2> >, 41 list< dim< DT3,static_rational<E3> >, 42 list< dim< DT4,static_rational<E4> >, 43 list< dim< DT5,static_rational<E5> >, 44 list< dim< DT6,static_rational<E6> >, 45 list< dim< DT7,static_rational<E7> >, 46 list< dim< DT8,static_rational<E8> >, dimensionless_type > > > > > > > > >::type type; 47 #endif 48 }; 49 50 /// INTERNAL ONLY 51 template<class DT1,long E1> 52 struct derived_dimension< 53 DT1, E1, 54 dimensionless_type,0, 55 dimensionless_type,0, 56 dimensionless_type,0, 57 dimensionless_type,0, 58 dimensionless_type,0, 59 dimensionless_type,0, 60 dimensionless_type,0> 61 { 62 typedef typename 63 make_dimension_list< list< dim< DT1,static_rational<E1> >, dimensionless_type > >::type type; 64 }; 65 66 /// INTERNAL ONLY 67 template<class DT1,long E1, 68 class DT2,long E2> 69 struct derived_dimension< 70 DT1, E1, 71 DT2, E2, 72 dimensionless_type,0, 73 dimensionless_type,0, 74 dimensionless_type,0, 75 dimensionless_type,0, 76 dimensionless_type,0, 77 dimensionless_type,0> 78 { 79 typedef typename 80 make_dimension_list< list< dim< DT1,static_rational<E1> >, 81 list< dim< DT2,static_rational<E2> >, dimensionless_type > > >::type type; 82 }; 83 84 /// INTERNAL ONLY 85 template<class DT1,long E1, 86 class DT2,long E2, 87 class DT3,long E3> 88 struct derived_dimension< 89 DT1, E1, 90 DT2, E2, 91 DT3, E3, 92 dimensionless_type,0, 93 dimensionless_type,0, 94 dimensionless_type,0, 95 dimensionless_type,0, 96 dimensionless_type,0> 97 { 98 typedef typename 99 make_dimension_list< list< dim< DT1,static_rational<E1> >, 100 list< dim< DT2,static_rational<E2> >, 101 list< dim< DT3,static_rational<E3> >, dimensionless_type > > > >::type type; 102 }; 103 104 /// INTERNAL ONLY 105 template<class DT1,long E1, 106 class DT2,long E2, 107 class DT3,long E3, 108 class DT4,long E4> 109 struct derived_dimension< 110 DT1, E1, 111 DT2, E2, 112 DT3, E3, 113 DT4, E4, 114 dimensionless_type,0, 115 dimensionless_type,0, 116 dimensionless_type,0, 117 dimensionless_type,0> 118 { 119 typedef typename 120 make_dimension_list< list< dim< DT1,static_rational<E1> >, 121 list< dim< DT2,static_rational<E2> >, 122 list< dim< DT3,static_rational<E3> >, 123 list< dim< DT4,static_rational<E4> >, dimensionless_type > > > > >::type type; 124 }; 125 126 /// INTERNAL ONLY 127 template<class DT1,long E1, 128 class DT2,long E2, 129 class DT3,long E3, 130 class DT4,long E4, 131 class DT5,long E5> 132 struct derived_dimension< 133 DT1, E1, 134 DT2, E2, 135 DT3, E3, 136 DT4, E4, 137 DT5, E5, 138 dimensionless_type,0, 139 dimensionless_type,0, 140 dimensionless_type,0> 141 { 142 typedef typename 143 make_dimension_list< list< dim< DT1,static_rational<E1> >, 144 list< dim< DT2,static_rational<E2> >, 145 list< dim< DT3,static_rational<E3> >, 146 list< dim< DT4,static_rational<E4> >, 147 list< dim< DT5,static_rational<E5> >, dimensionless_type > > > > > >::type type; 148 }; 149 150 /// INTERNAL ONLY 151 template<class DT1,long E1, 152 class DT2,long E2, 153 class DT3,long E3, 154 class DT4,long E4, 155 class DT5,long E5, 156 class DT6,long E6> 157 struct derived_dimension< 158 DT1, E1, 159 DT2, E2, 160 DT3, E3, 161 DT4, E4, 162 DT5, E5, 163 DT6, E6, 164 dimensionless_type,0, 165 dimensionless_type,0> 166 { 167 typedef typename 168 make_dimension_list< list< dim< DT1,static_rational<E1> >, 169 list< dim< DT2,static_rational<E2> >, 170 list< dim< DT3,static_rational<E3> >, 171 list< dim< DT4,static_rational<E4> >, 172 list< dim< DT5,static_rational<E5> >, 173 list< dim< DT6,static_rational<E6> >, dimensionless_type > > > > > > >::type type; 174 }; 175 176 /// INTERNAL ONLY 177 template<class DT1,long E1, 178 class DT2,long E2, 179 class DT3,long E3, 180 class DT4,long E4, 181 class DT5,long E5, 182 class DT6,long E6, 183 class DT7,long E7> 184 struct derived_dimension< 185 DT1, E1, 186 DT2, E2, 187 DT3, E3, 188 DT4, E4, 189 DT5, E5, 190 DT6, E6, 191 DT7, E7, 192 dimensionless_type,0> 193 { 194 typedef typename 195 make_dimension_list< list< dim< DT1,static_rational<E1> >, 196 list< dim< DT2,static_rational<E2> >, 197 list< dim< DT3,static_rational<E3> >, 198 list< dim< DT4,static_rational<E4> >, 199 list< dim< DT5,static_rational<E5> >, 200 list< dim< DT6,static_rational<E6> >, 201 list< dim< DT7,static_rational<E7> >, dimensionless_type > > > > > > > >::type type; 202 }; 203 204 } // namespace units 205 206 } // namespace boost 207 208 #endif // BOOST_UNITS_DERIVED_DIMENSION_HPP 209