dim_impl.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_DIM_IMPL_HPP
  11. #define BOOST_UNITS_DIM_IMPL_HPP
  12. #include <boost/mpl/bool.hpp>
  13. #include <boost/mpl/less.hpp>
  14. #include <boost/units/units_fwd.hpp>
  15. /// \file
  16. /// \brief Class encapsulating a dimension tag/value pair
  17. namespace boost {
  18. namespace units {
  19. namespace detail {
  20. struct dim_tag;
  21. }
  22. }
  23. namespace mpl {
  24. /// Less than comparison for sorting @c dim.
  25. template<>
  26. struct less_impl<boost::units::detail::dim_tag, boost::units::detail::dim_tag>
  27. {
  28. template<class T0, class T1>
  29. struct apply : mpl::less<typename T0::tag_type, typename T1::tag_type> {};
  30. };
  31. }
  32. namespace units {
  33. template<class Tag, class Exponent>
  34. struct dim;
  35. template<long N, long D>
  36. class static_rational;
  37. namespace detail {
  38. /// Extract @c tag_type from a @c dim.
  39. template<typename T>
  40. struct get_tag
  41. {
  42. typedef typename T::tag_type type;
  43. };
  44. /// Extract @c value_type from a @c dim.
  45. template<typename T>
  46. struct get_value
  47. {
  48. typedef typename T::value_type type;
  49. };
  50. /// Determine if a @c dim is empty (has a zero exponent).
  51. template<class T>
  52. struct is_empty_dim;
  53. template<typename T>
  54. struct is_empty_dim< dim<T, static_rational<0, 1> > > :
  55. mpl::true_
  56. { };
  57. template<typename T, typename V>
  58. struct is_empty_dim< dim<T, V> > :
  59. mpl::false_
  60. { };
  61. } // namespace detail
  62. } // namespace units
  63. } // namespace boost
  64. #endif // BOOST_UNITS_DIM_IMPL_HPP