12#include <boost/static_assert.hpp>
14#include <boost/mpl/equal.hpp>
15#include <boost/mpl/transform.hpp>
16#include <boost/mpl/vector_c.hpp>
18#include <boost/mpl/placeholders.hpp>
19using namespace boost::mpl::placeholders;
40namespace section_3_1 {
43typedef boost::mpl::vector_c<int, 0, 0, 0, 0, 0, 0, 0>
scalar;
46typedef boost::mpl::vector_c<int, 1, 0, 0, 0, 0, 0, 0>
mass;
47typedef boost::mpl::vector_c<int, 0, 1, 0, 0, 0, 0, 0>
length;
48typedef boost::mpl::vector_c<int, 0, 0, 1, 0, 0, 0, 0>
time;
49typedef boost::mpl::vector_c<int, 0, 0, 0, 1, 0, 0, 0>
charge;
50typedef boost::mpl::vector_c<int, 0, 0, 0, 0, 1, 0, 0>
temperature;
51typedef boost::mpl::vector_c<int, 0, 0, 0, 0, 0, 1, 0>
intensity;
55typedef boost::mpl::vector_c<int, 0, 1, -1, 0, 0, 0, 0>
velocity;
56typedef boost::mpl::vector_c<int, 0, 1, -2, 0, 0, 0, 0>
acceleration;
57typedef boost::mpl::vector_c<int, 1, 1, -1, 0, 0, 0, 0>
momentum;
58typedef boost::mpl::vector_c<int, 1, 1, -2, 0, 0, 0, 0>
force;
70template <
typename T,
typename Dimension>
93 template <
typename OtherDimension>
98 (boost::mpl::equal<Dimension,OtherDimension>::type::value));
126template <
typename T,
typename D1,
typename D2>
147template <
typename T,
typename D1,
typename D2>
165template<
typename D1,
typename D2>
167 : boost::mpl::transform<D1,D2,boost::mpl::minus<_1,_2> > { };
178template<
typename D1,
typename D2>
180 : boost::mpl::transform<D1,D2,boost::mpl::plus<_1,_2> > { };
195template <
typename T,
typename D1,
typename D2>
200 x.value() * y.value());
216template <
typename T,
typename D1,
typename D2>
217quantity<T, typename divide_dimensions<D1,D2>::type>
221 x.value() / y.value());
BOOST_STATIC_ASSERT((boost::is_same< t5, expected_t5 >::value))
A numerical quanitity with intrinsic dimensions.
T m_value
The current value of this quantity.
T value() const
Return the current quantity's value.
quantity(T const x)
Construct this quantity with an initial value.
quantity(quantity< T, OtherDimension > const &rhs)
Construct a quantity from another quantity with (possibly) different dimensions.
boost::mpl::vector_c< int, 1, 1, -1, 0, 0, 0, 0 > momentum
boost::mpl::vector_c< int, 1, 1, -2, 0, 0, 0, 0 > force
quantity< T, typename multiply_dimensions< D1, D2 >::type > operator*(quantity< T, D1 > const &x, quantity< T, D2 > const &y)
Multiply two quantities.
boost::mpl::vector_c< int, 0, 0, 0, 0, 1, 0, 0 > temperature
boost::mpl::vector_c< int, 0, 0, 1, 0, 0, 0, 0 > time
boost::mpl::vector_c< int, 0, 0, 0, 0, 0, 1, 0 > intensity
boost::mpl::vector_c< int, 0, 1, 0, 0, 0, 0, 0 > length
boost::mpl::vector_c< int, 0, 0, 0, 0, 0, 0, 0 > scalar
boost::mpl::vector_c< int, 0, 1, -1, 0, 0, 0, 0 > velocity
quantity< T, typename divide_dimensions< D1, D2 >::type > operator/(quantity< T, D1 > const &x, quantity< T, D2 > const &y)
Divide two quantities.
quantity< T, D1 > operator+(quantity< T, D1 > const &x, quantity< T, D2 > const &y)
Add two quantities.
boost::mpl::vector_c< int, 0, 0, 0, 1, 0, 0, 0 > charge
quantity< T, D1 > operator-(quantity< T, D1 > const &x, quantity< T, D2 > const &y)
Subtract two quantities.
boost::mpl::vector_c< int, 1, 0, 0, 0, 0, 0, 0 > mass
boost::mpl::vector_c< int, 0, 1, -2, 0, 0, 0, 0 > acceleration
boost::mpl::vector_c< int, 0, 0, 0, 0, 0, 0, 1 > amount_of_substance
Encapsulate solution for Exercise 3-5.
Divide all elements of two dimension sequences.
Multiply all elements of two dimension sequences.