derived_dimension.hpp 6.3 KB

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