123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- #ifndef BOOST_UNITS_DIM_HPP
- #define BOOST_UNITS_DIM_HPP
- #include <boost/static_assert.hpp>
- #include <boost/type_traits/is_same.hpp>
- #include <boost/mpl/arithmetic.hpp>
- #include <boost/units/config.hpp>
- #include <boost/units/static_rational.hpp>
- #include <boost/units/detail/dim_impl.hpp>
- namespace boost {
- namespace units {
- namespace detail {
- struct dim_tag { };
- }
- template<typename T,typename V>
- struct dim
- {
- typedef dim type;
- typedef detail::dim_tag tag;
- typedef T tag_type;
- typedef V value_type;
- };
- }
- }
- #if BOOST_UNITS_HAS_BOOST_TYPEOF
- #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
- BOOST_TYPEOF_REGISTER_TEMPLATE(boost::units::dim, 2)
- #endif
- #ifndef BOOST_UNITS_DOXYGEN
- namespace boost {
- namespace mpl {
- template<>
- struct plus_impl<boost::units::detail::dim_tag,boost::units::detail::dim_tag>
- {
- template<class T0, class T1>
- struct apply
- {
- BOOST_STATIC_ASSERT((boost::is_same<typename T0::tag_type,typename T1::tag_type>::value == true));
- typedef boost::units::dim<typename T0::tag_type, typename mpl::plus<typename T0::value_type, typename T1::value_type>::type> type;
- };
- };
- template<>
- struct minus_impl<boost::units::detail::dim_tag,boost::units::detail::dim_tag>
- {
- template<class T0, class T1>
- struct apply
- {
- BOOST_STATIC_ASSERT((boost::is_same<typename T0::tag_type,typename T1::tag_type>::value == true));
- typedef boost::units::dim<typename T0::tag_type, typename mpl::minus<typename T0::value_type, typename T1::value_type>::type> type;
- };
- };
- template<>
- struct times_impl<boost::units::detail::dim_tag,boost::units::detail::static_rational_tag>
- {
- template<class T0, class T1>
- struct apply
- {
- typedef boost::units::dim<typename T0::tag_type, typename mpl::times<typename T0::value_type, T1>::type> type;
- };
- };
- template<>
- struct times_impl<boost::units::detail::static_rational_tag,boost::units::detail::dim_tag>
- {
- template<class T0, class T1>
- struct apply
- {
- typedef boost::units::dim<typename T1::tag_type, typename mpl::times<T0, typename T1::value_type>::type> type;
- };
- };
- template<>
- struct divides_impl<boost::units::detail::dim_tag,boost::units::detail::static_rational_tag>
- {
- template<class T0, class T1>
- struct apply
- {
- typedef boost::units::dim<typename T0::tag_type, typename mpl::divides<typename T0::value_type, T1>::type> type;
- };
- };
- template<>
- struct divides_impl<boost::units::detail::static_rational_tag,boost::units::detail::dim_tag>
- {
- template<class T0, class T1>
- struct apply
- {
- typedef boost::units::dim<typename T1::tag_type, typename mpl::divides<T0, typename T1::value_type>::type> type;
- };
- };
- template<>
- struct negate_impl<boost::units::detail::dim_tag>
- {
- template<class T0>
- struct apply
- {
- typedef boost::units::dim<typename T0::tag_type,typename mpl::negate<typename T0::value_type>::type> type;
- };
- };
- }
- }
- #endif
- #endif
|