// mcs::units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2007 Matthias Christian Schabel // Copyright (C) 2007 Steven Watanabe // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include #include #include namespace boost { namespace units { struct length_base_dimension : boost::units::base_dimension { }; ///> base dimension of length struct mass_base_dimension : boost::units::base_dimension { }; ///> base dimension of mass struct time_base_dimension : boost::units::base_dimension { }; ///> base dimension of time typedef length_base_dimension::type length_dimension; typedef mass_base_dimension::type mass_dimension; typedef time_base_dimension::type time_dimension; struct centimeter_base_unit : base_unit { }; struct gram_base_unit : base_unit { }; struct second_base_unit : base_unit { }; namespace CG { typedef make_system::type system; /// unit typedefs typedef unit dimensionless; typedef unit length; typedef unit mass; /// unit constants BOOST_UNITS_STATIC_CONSTANT(centimeter,length); BOOST_UNITS_STATIC_CONSTANT(gram,mass); } // namespace CGS namespace CGS { typedef make_system::type system; /// unit typedefs typedef unit dimensionless; typedef unit length; typedef unit mass; typedef unit time; /// unit constants BOOST_UNITS_STATIC_CONSTANT(centimeter,length); BOOST_UNITS_STATIC_CONSTANT(gram,mass); BOOST_UNITS_STATIC_CONSTANT(second,time); } // namespace CGS namespace esu { /// derived dimension for charge in electrostatic units : L^3/2 M^1/2 T^-1 typedef make_dimension_list< mpl::list< dim >, dim >, dim > > >::type charge_dimension; typedef unit charge; } // namespace esu template<> struct base_unit_info { static std::string name() { return "centimeter"; } static std::string symbol() { return "cm"; } }; template<> struct base_unit_info { static std::string name() { return "gram"; } static std::string symbol() { return "g"; } }; template<> struct base_unit_info { static std::string name() { return "second"; } static std::string symbol() { return "s"; } }; } // namespace units } // namespace boost int main(void) { using namespace boost::units; using namespace boost::units::CGS; quantity cg_length(1.5*CG::centimeter); quantity cgs_length(1.5*CGS::centimeter); std::cout << cg_length/cgs_length << std::endl; //std::cout << root<2>(gram*pow<3>(centimeter)/pow<2>(second)) << std::endl; return 0; }