// Boost.Units - A C++ library for zero-overhead dimensional analysis and // unit/quantity manipulation and conversion // // Copyright (C) 2003-2008 Matthias Christian Schabel // Copyright (C) 2007-2008 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 #include #include #include #include #include #include namespace test_system1 { // the base units in the system will be: // // volts = m^2 kg s^-2 C^-1 // newtons = m kg s^-2 // joules = m^2 kg s^-2 // we will find the representation of m^-1 C^-1 = V N J^-2 = m^-1 C^-1 // reducing the system should generate the matrix equation // 2 1 2 // 1 1 1 x = c // -2 -2 -2 // -1 0 0 struct volt : boost::units::base_unit {}; struct newton : boost::units::base_unit {}; struct joule : boost::units::base_unit {}; typedef boost::units::make_system::type complicated_system; typedef boost::units::derived_dimension< boost::units::length_base_dimension, -1, boost::units::time_base_dimension, -1, boost::units::current_base_dimension, -1 >::type dimension; typedef boost::units::reduce_unit >::type reduced; typedef boost::units::divide_typeof_helper< boost::units::multiply_typeof_helper::type, boost::units::power_typeof_helper >::type >::type expected; void test() { BOOST_MPL_ASSERT((boost::is_same)); } } namespace test_system2 { // the base units in the system will be: // // kilograms = kg // meters = m // we will find the representation of m and kg // reducing the system should generate the matrix equation // 0 1 // 1 0 x = c struct kilogram : boost::units::base_unit {}; struct meter : boost::units::base_unit {}; typedef boost::units::make_system::type mk_system; typedef boost::units::reduce_unit >::type mass_unit; typedef boost::units::reduce_unit >::type length_unit; void test() { BOOST_MPL_ASSERT((boost::is_same)); BOOST_MPL_ASSERT((boost::is_same)); } }