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 11 #ifndef BOOST_UNITS_DETAIL_DIMENSIONLESS_UNIT_HPP 12 #define BOOST_UNITS_DETAIL_DIMENSIONLESS_UNIT_HPP 13 14 #include <boost/mpl/bool.hpp> 15 #include <boost/units/units_fwd.hpp> 16 17 namespace boost { 18 namespace units { 19 20 template<class T> 21 struct heterogeneous_system; 22 23 template<class T> 24 struct homogeneous_system; 25 26 template<class T1, class T2, class Scale> 27 struct heterogeneous_system_impl; 28 29 typedef boost::units::heterogeneous_system< 30 boost::units::heterogeneous_system_impl< 31 boost::units::dimensionless_type, 32 boost::units::dimensionless_type, 33 boost::units::dimensionless_type 34 > 35 > heterogeneous_dimensionless_system; 36 37 namespace detail { 38 39 template<class System> 40 struct void_if_dimensionless { 41 typedef int type; 42 }; 43 44 template<class T> 45 struct void_if_dimensionless<boost::units::homogeneous_system<T> > { 46 typedef void type; 47 }; 48 49 template<> 50 struct void_if_dimensionless<heterogeneous_dimensionless_system> { 51 typedef void type; 52 }; 53 54 template<class System, class Test = void> 55 struct void_if_heterogeneous { 56 typedef void type; 57 }; 58 59 template<class System> 60 struct void_if_heterogeneous<System, typename void_if_dimensionless<System>::type> { 61 typedef int type; 62 }; 63 64 template<class System, class Enable=void> 65 struct is_dimensionless_system : mpl::false_ {}; 66 67 template<class System> 68 struct is_dimensionless_system<System, typename void_if_dimensionless<System>::type> : mpl::true_ {}; 69 70 #define BOOST_UNITS_DIMENSIONLESS_UNIT(T)\ 71 boost::units::unit<\ 72 boost::units::dimensionless_type,\ 73 T,\ 74 typename ::boost::units::detail::void_if_dimensionless<T>::type\ 75 > 76 77 #define BOOST_UNITS_HETEROGENEOUS_DIMENSIONLESS_UNIT(T)\ 78 boost::units::unit<\ 79 boost::units::dimensionless_type,\ 80 T,\ 81 typename ::boost::units::detail::void_if_heterogeneous<T>::type\ 82 > 83 84 } 85 } 86 } 87 88 #endif 89