12#include <boost/static_assert.hpp>
14#include <boost/mpl/begin_end.hpp>
15#include <boost/mpl/deref.hpp>
16#include <boost/mpl/equal.hpp>
17#include <boost/mpl/greater_equal.hpp>
18#include <boost/mpl/push_back.hpp>
19#include <boost/mpl/times.hpp>
20#include <boost/mpl/vector_c.hpp>
56template <
typename S,
typename Res,
typename Cur>
62 typedef boost::mpl::distance<typename boost::mpl::begin<S>::type, Cur>
66 typedef boost::mpl::distance<Cur, typename boost::mpl::end<S>::type>
72 boost::mpl::greater_equal<dist_to_begin, dist_to_end>,
73 boost::mpl::deref<Cur>,
75 typename boost::mpl::deref<Cur>::type,
85 boost::is_same<Cur, typename boost::mpl::end<S>::type>,
89 typename boost::mpl::push_back<
91 typename multiply_or_not::type
93 typename boost::mpl::next<Cur>::type
126 S, boost::mpl::vector_c<int>, typename boost::mpl::begin<S>::type>
Represents a single iteration across the sequence.
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.
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.
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.
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.
Encapsulate solution for Exercise 5-1.
Double the values in the first half of the given sequence.