C++ Template Metaprogramming
Solutions to the exercises throughout the book
|
Modification of algorithms from Chapter 3, Section 1. More...
Classes | |
struct | divide_dimensions |
Divide all elements of two dimension sequences. More... | |
struct | multiply_dimensions |
Multiply all elements of two dimension sequences. More... | |
class | quantity |
A numerical quanitity with intrinsic dimensions. More... | |
Typedefs | |
typedef boost::mpl::vector_c< int, 0, 0, 0, 0, 0, 0, 0 > | scalar |
typedef boost::mpl::vector_c< int, 1, 0, 0, 0, 0, 0, 0 > | mass |
typedef boost::mpl::vector_c< int, 0, 1, 0, 0, 0, 0, 0 > | length |
typedef boost::mpl::vector_c< int, 0, 0, 1, 0, 0, 0, 0 > | time |
typedef boost::mpl::vector_c< int, 0, 0, 0, 1, 0, 0, 0 > | charge |
typedef boost::mpl::vector_c< int, 0, 0, 0, 0, 1, 0, 0 > | temperature |
typedef boost::mpl::vector_c< int, 0, 0, 0, 0, 0, 1, 0 > | intensity |
typedef boost::mpl::vector_c< int, 0, 0, 0, 0, 0, 0, 1 > | amount_of_substance |
typedef boost::mpl::vector_c< int, 0, 1, -1, 0, 0, 0, 0 > | velocity |
typedef boost::mpl::vector_c< int, 0, 1, -2, 0, 0, 0, 0 > | acceleration |
typedef boost::mpl::vector_c< int, 1, 1, -1, 0, 0, 0, 0 > | momentum |
typedef boost::mpl::vector_c< int, 1, 1, -2, 0, 0, 0, 0 > | force |
Functions | |
template<typename T , typename D1 , typename D2 > | |
quantity< T, D1 > | operator+ (quantity< T, D1 > const &x, quantity< T, D2 > const &y) |
Add two quantities. | |
template<typename T , typename D1 , typename D2 > | |
quantity< T, D1 > | operator- (quantity< T, D1 > const &x, quantity< T, D2 > const &y) |
Subtract two quantities. | |
template<typename T , typename D1 , typename D2 > | |
quantity< T, typename multiply_dimensions< D1, D2 >::type > | operator* (quantity< T, D1 > const &x, quantity< T, D2 > const &y) |
Multiply two quantities. | |
template<typename T , typename D1 , typename D2 > | |
quantity< T, typename divide_dimensions< D1, D2 >::type > | operator/ (quantity< T, D1 > const &x, quantity< T, D2 > const &y) |
Divide two quantities. | |
Modification of algorithms from Chapter 3, Section 1.
typedef boost::mpl::vector_c<int, 0, 1, -2, 0, 0, 0, 0> exercise_3_5::section_3_1::acceleration |
Definition at line 56 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 0, 0, 0, 0, 0, 0, 1> exercise_3_5::section_3_1::amount_of_substance |
Definition at line 52 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 0, 0, 0, 1, 0, 0, 0> exercise_3_5::section_3_1::charge |
Definition at line 49 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 1, 1, -2, 0, 0, 0, 0> exercise_3_5::section_3_1::force |
Definition at line 58 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 0, 0, 0, 0, 0, 1, 0> exercise_3_5::section_3_1::intensity |
Definition at line 51 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 0, 1, 0, 0, 0, 0, 0> exercise_3_5::section_3_1::length |
Definition at line 47 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 1, 0, 0, 0, 0, 0, 0> exercise_3_5::section_3_1::mass |
Definition at line 46 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 1, 1, -1, 0, 0, 0, 0> exercise_3_5::section_3_1::momentum |
Definition at line 57 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 0, 0, 0, 0, 0, 0, 0> exercise_3_5::section_3_1::scalar |
Definition at line 43 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 0, 0, 0, 0, 1, 0, 0> exercise_3_5::section_3_1::temperature |
Definition at line 50 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 0, 0, 1, 0, 0, 0, 0> exercise_3_5::section_3_1::time |
Definition at line 48 of file exercise-3-5.hpp.
typedef boost::mpl::vector_c<int, 0, 1, -1, 0, 0, 0, 0> exercise_3_5::section_3_1::velocity |
Definition at line 55 of file exercise-3-5.hpp.
quantity< T, typename multiply_dimensions< D1, D2 >::type > exercise_3_5::section_3_1::operator* | ( | quantity< T, D1 > const & | x, |
quantity< T, D2 > const & | y | ||
) |
Multiply two quantities.
T | The container type for the quantity's value. |
D1 | The first quantity's dimensions. |
D2 | The second quantity's dimensions. |
[in] | x | The first quantity to multiply. |
[in] | y | The second quantity to multiply. |
Definition at line 197 of file exercise-3-5.hpp.
quantity< T, D1 > exercise_3_5::section_3_1::operator+ | ( | quantity< T, D1 > const & | x, |
quantity< T, D2 > const & | y | ||
) |
Add two quantities.
T | The container type for the quantity's value. |
D1 | The quantity's resulting dimensions. |
D2 | Dimensions for an input quantity that are compatible with the output dimensions. |
[in] | x | The first quantity to add. |
[in] | y | The second quantity to add. |
Definition at line 127 of file exercise-3-5.hpp.
quantity< T, D1 > exercise_3_5::section_3_1::operator- | ( | quantity< T, D1 > const & | x, |
quantity< T, D2 > const & | y | ||
) |
Subtract two quantities.
T | The container type for the quantity's value. |
D1 | The quantity's resulting dimensions. |
D2 | Dimensions for an input quantity that are compatible with the output dimensions. |
[in] | x | The first quantity to subtract. |
[in] | y | The second quantity to subtract. |
Definition at line 148 of file exercise-3-5.hpp.
quantity< T, typename divide_dimensions< D1, D2 >::type > exercise_3_5::section_3_1::operator/ | ( | quantity< T, D1 > const & | x, |
quantity< T, D2 > const & | y | ||
) |
Divide two quantities.
T | The container type for the quantity's value. |
D1 | The first quantity's dimensions. |
D2 | The second quantity's dimensions. |
[in] | x | The first quantity to divide. |
[in] | y | The second quantity to divide. |
Definition at line 218 of file exercise-3-5.hpp.