get_dimension.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_GET_DIMENSION_HPP
  11. #define BOOST_UNITS_GET_DIMENSION_HPP
  12. ///
  13. /// \file
  14. /// \brief Get the dimension of a unit, absolute unit and quantity.
  15. /// \details
  16. ///
  17. #include <boost/units/units_fwd.hpp>
  18. namespace boost {
  19. namespace units {
  20. template<class T>
  21. struct get_dimension {};
  22. /// Get the dimension of a unit.
  23. template<class Dim,class System>
  24. struct get_dimension< unit<Dim,System> >
  25. {
  26. typedef Dim type;
  27. };
  28. /// Get the dimension of an absolute unit.
  29. template<class Unit>
  30. struct get_dimension< absolute<Unit> >
  31. {
  32. typedef typename get_dimension<Unit>::type type;
  33. };
  34. /// Get the dimension of a quantity.
  35. template<class Unit,class Y>
  36. struct get_dimension< quantity<Unit,Y> >
  37. {
  38. typedef typename get_dimension<Unit>::type type;
  39. };
  40. } // namespace units
  41. } // namespace boost
  42. #endif // BOOST_UNITS_GET_DIMENSION_HPP