make_scaled_unit.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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) 2007-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_MAKE_SCALED_UNIT_HPP_INCLUDED
  11. #define BOOST_UNITS_MAKE_SCALED_UNIT_HPP_INCLUDED
  12. #include <boost/units/units_fwd.hpp>
  13. #include <boost/units/heterogeneous_system.hpp>
  14. #include <boost/units/unit.hpp>
  15. namespace boost {
  16. namespace units {
  17. template<class Unit, class Scale>
  18. struct make_scaled_unit {
  19. typedef typename make_scaled_unit<typename reduce_unit<Unit>::type, Scale>::type type;
  20. };
  21. template<class Dimension, class UnitList, class OldScale, class Scale>
  22. struct make_scaled_unit<unit<Dimension, heterogeneous_system<heterogeneous_system_impl<UnitList, Dimension, OldScale> > >, Scale> {
  23. typedef unit<
  24. Dimension,
  25. heterogeneous_system<
  26. heterogeneous_system_impl<
  27. UnitList,
  28. Dimension,
  29. typename mpl::times<
  30. OldScale,
  31. list<scale_list_dim<Scale>, dimensionless_type>
  32. >::type
  33. >
  34. >
  35. > type;
  36. };
  37. template<class Dimension, class UnitList, class OldScale, long Base>
  38. struct make_scaled_unit<unit<Dimension, heterogeneous_system<heterogeneous_system_impl<UnitList, Dimension, OldScale> > >, scale<Base, static_rational<0> > > {
  39. typedef unit<
  40. Dimension,
  41. heterogeneous_system<
  42. heterogeneous_system_impl<
  43. UnitList,
  44. Dimension,
  45. OldScale
  46. >
  47. >
  48. > type;
  49. };
  50. }
  51. }
  52. #endif