|
C++ Template Metaprogramming
Solutions to the exercises throughout the book
|
Double the numbers in the first half of a RandomAccessSequence.
More...
Files | |
| file | exercise-5-1.hpp |
| Solution to Exercise 5-1. | |
Namespaces | |
| namespace | test_5_1 |
| Tests functionality from Exercise 5-1. | |
| namespace | exercise_5_1 |
| Encapsulate solution for Exercise 5-1. | |
Double the numbers in the first half of a RandomAccessSequence.
5-1. Write a metafunction double_first_half that takes a RandomAccessSequence
of integral constant wrappers of length N as an argument, and returns a
copy with the first N/2 elements doubled in value, such that the
following is true:
mpl::equal<
double_first_half< mpl::vector_c<int,1,2,3,4> >::type,
mpl::vector_c<int,2,4,3,4>
>::type::value