|
C++ Template Metaprogramming
Solutions to the exercises throughout the book
|
Solution to Exercise 3-5. More...
#include <boost/static_assert.hpp>#include <boost/mpl/equal.hpp>#include <boost/mpl/transform.hpp>#include <boost/mpl/vector_c.hpp>#include <boost/mpl/placeholders.hpp>Go to the source code of this file.
Classes | |
| class | exercise_3_5::section_3_1::quantity< T, Dimension > |
| A numerical quanitity with intrinsic dimensions. More... | |
| struct | exercise_3_5::section_3_1::divide_dimensions< D1, D2 > |
| Divide all elements of two dimension sequences. More... | |
| struct | exercise_3_5::section_3_1::multiply_dimensions< D1, D2 > |
| Multiply all elements of two dimension sequences. More... | |
Namespaces | |
| namespace | exercise_3_5 |
| Encapsulate solution for Exercise 3-5. | |
| namespace | exercise_3_5::section_3_1 |
| Modification of algorithms from Chapter 3, Section 1. | |
Typedefs | |
| typedef boost::mpl::vector_c< int, 0, 0, 0, 0, 0, 0, 0 > | exercise_3_5::section_3_1::scalar |
| typedef boost::mpl::vector_c< int, 1, 0, 0, 0, 0, 0, 0 > | exercise_3_5::section_3_1::mass |
| typedef boost::mpl::vector_c< int, 0, 1, 0, 0, 0, 0, 0 > | exercise_3_5::section_3_1::length |
| typedef boost::mpl::vector_c< int, 0, 0, 1, 0, 0, 0, 0 > | exercise_3_5::section_3_1::time |
| typedef boost::mpl::vector_c< int, 0, 0, 0, 1, 0, 0, 0 > | exercise_3_5::section_3_1::charge |
| typedef boost::mpl::vector_c< int, 0, 0, 0, 0, 1, 0, 0 > | exercise_3_5::section_3_1::temperature |
| typedef boost::mpl::vector_c< int, 0, 0, 0, 0, 0, 1, 0 > | exercise_3_5::section_3_1::intensity |
| typedef boost::mpl::vector_c< int, 0, 0, 0, 0, 0, 0, 1 > | exercise_3_5::section_3_1::amount_of_substance |
| typedef boost::mpl::vector_c< int, 0, 1, -1, 0, 0, 0, 0 > | exercise_3_5::section_3_1::velocity |
| typedef boost::mpl::vector_c< int, 0, 1, -2, 0, 0, 0, 0 > | exercise_3_5::section_3_1::acceleration |
| typedef boost::mpl::vector_c< int, 1, 1, -1, 0, 0, 0, 0 > | exercise_3_5::section_3_1::momentum |
| typedef boost::mpl::vector_c< int, 1, 1, -2, 0, 0, 0, 0 > | exercise_3_5::section_3_1::force |
Functions | |
| template<typename T , typename D1 , typename D2 > | |
| quantity< T, D1 > | exercise_3_5::section_3_1::operator+ (quantity< T, D1 > const &x, quantity< T, D2 > const &y) |
| Add two quantities. | |
| template<typename T , typename D1 , typename D2 > | |
| quantity< T, D1 > | exercise_3_5::section_3_1::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 > | exercise_3_5::section_3_1::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 > | exercise_3_5::section_3_1::operator/ (quantity< T, D1 > const &x, quantity< T, D2 > const &y) |
| Divide two quantities. | |
Solution to Exercise 3-5.
Definition in file exercise-3-5.hpp.