C++ Template Metaprogramming
Solutions to the exercises throughout the book
|
Represents a single iteration across the sequence. More...
#include <exercise-5-1.hpp>
Public Types | |
typedef boost::mpl::eval_if< boost::is_same< Cur, typenameboost::mpl::end< S >::type >, Res, double_first_half_impl< S, typenameboost::mpl::push_back< Res, typenamemultiply_or_not::type >::type, typenameboost::mpl::next< Cur >::type > >::type | type |
Produce a result and keep iterating until we reach the end. | |
Private Types | |
typedef boost::mpl::distance< typename boost::mpl::begin< S >::type, Cur > | dist_to_begin |
The distance from the beginning of the sequence to where we are. | |
typedef boost::mpl::distance< Cur, typename boost::mpl::end< S >::type > | dist_to_end |
The distance from the end of the sequence to where we are. | |
typedef boost::mpl::eval_if< boost::mpl::greater_equal< dist_to_begin, dist_to_end >, boost::mpl::deref< Cur >, boost::mpl::times< typename boost::mpl::deref< Cur >::type, boost::mpl::int_< 2 > > > | multiply_or_not |
Lazily decide what operation to use if we're past the midpoint. | |
Represents a single iteration across the sequence.
This metafunction computes the mid-point, decides what operation to perform on the element, folds the result into the destination, and kicks off the next iteration. This is part of the algorithm for double_first_half
.
S | The input sequence (needed to measure distances). |
Res | The resulting sequence. |
Cur | The iterator to the current location in S . |
Definition at line 57 of file exercise-5-1.hpp.
|
private |
The distance from the beginning of the sequence to where we are.
Definition at line 63 of file exercise-5-1.hpp.
|
private |
The distance from the end of the sequence to where we are.
Definition at line 67 of file exercise-5-1.hpp.
|
private |
Lazily decide what operation to use if we're past the midpoint.
Definition at line 78 of file exercise-5-1.hpp.
typedef boost::mpl::eval_if<boost::is_same<Cur,typenameboost::mpl::end<S>::type>,Res,double_first_half_impl<S,typenameboost::mpl::push_back<Res,typenamemultiply_or_not::type>::type,typenameboost::mpl::next<Cur>::type>>::type exercise_5_1::double_first_half_impl< S, Res, Cur >::type |
Produce a result and keep iterating until we reach the end.
Definition at line 95 of file exercise-5-1.hpp.