Chris@16: // Boost.Units - A C++ library for zero-overhead dimensional analysis and Chris@16: // unit/quantity manipulation and conversion Chris@16: // Chris@16: // Copyright (C) 2003-2008 Matthias Christian Schabel Chris@16: // Copyright (C) 2008 Steven Watanabe Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_UNITS_DETAIL_ONE_HPP Chris@16: #define BOOST_UNITS_DETAIL_ONE_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: namespace units { Chris@16: Chris@16: struct one { one() {} }; Chris@16: Chris@16: // workaround for pathscale. Chris@16: inline one make_one() { Chris@16: one result; Chris@16: return(result); Chris@16: } Chris@16: Chris@16: template Chris@16: struct multiply_typeof_helper Chris@16: { Chris@16: typedef T type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct multiply_typeof_helper Chris@16: { Chris@16: typedef T type; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct multiply_typeof_helper Chris@16: { Chris@16: typedef one type; Chris@16: }; Chris@16: Chris@16: template Chris@16: inline T operator*(const one&, const T& t) Chris@16: { Chris@16: return(t); Chris@16: } Chris@16: Chris@16: template Chris@16: inline T operator*(const T& t, const one&) Chris@16: { Chris@16: return(t); Chris@16: } Chris@16: Chris@16: inline one operator*(const one&, const one&) Chris@16: { Chris@16: one result; Chris@16: return(result); Chris@16: } Chris@16: Chris@16: template Chris@16: struct divide_typeof_helper Chris@16: { Chris@16: typedef T type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct divide_typeof_helper Chris@16: { Chris@16: typedef T type; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct divide_typeof_helper Chris@16: { Chris@16: typedef one type; Chris@16: }; Chris@16: Chris@16: template Chris@16: inline T operator/(const T& t, const one&) Chris@16: { Chris@16: return(t); Chris@16: } Chris@16: Chris@16: template Chris@16: inline T operator/(const one&, const T& t) Chris@16: { Chris@16: return(1/t); Chris@16: } Chris@16: Chris@16: inline one operator/(const one&, const one&) Chris@16: { Chris@16: one result; Chris@16: return(result); Chris@16: } Chris@16: Chris@16: template Chris@16: inline bool operator>(const boost::units::one&, const T& t) { Chris@16: return(1 > t); Chris@16: } Chris@16: Chris@16: template Chris@16: T one_to_double(const T& t) { return t; } Chris@16: Chris@16: inline double one_to_double(const one&) { return 1.0; } Chris@16: Chris@16: template Chris@16: struct one_to_double_type { typedef T type; }; Chris@16: Chris@16: template<> Chris@16: struct one_to_double_type { typedef double type; }; Chris@16: Chris@16: } // namespace units Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #endif