17#include <boost/mpl/vector.hpp>
18using namespace boost::mpl::placeholders;
22#define PARANOID_DEBUG_TEST
43typedef boost::mpl::vector_c<int, 1, 2, 3, 4>
testVec;
48 boost::mpl::vector_c<int, 2, 4, 3, 4> >::value));
58typedef boost::mpl::advance_c<
59 boost::mpl::begin<exercise_5_8::fibonacci_series>::type,
63typedef boost::mpl::advance_c<i, 4>::type
j;
117#ifdef PARANOID_DEBUG_TEST
118typedef boost::mpl::begin< inorder_view<tree_seq_hard> >::type
tmp1;
119typedef boost::mpl::deref<tmp1>::type
tmp1d;
122typedef boost::mpl::next<tmp1>::type
tmp2;
123typedef boost::mpl::deref<tmp2>::type
tmp2d;
126typedef boost::mpl::next<tmp2>::type
tmp3;
127typedef boost::mpl::deref<tmp3>::type
tmp3d;
130typedef boost::mpl::next<tmp3>::type
tmp4;
131typedef boost::mpl::deref<tmp4>::type
tmp4d;
134typedef boost::mpl::next<tmp4>::type
tmp5;
135typedef boost::mpl::deref<tmp5>::type
tmp5d;
138typedef boost::mpl::next<tmp5>::type
tmp6;
139typedef boost::mpl::deref<tmp6>::type
tmp6d;
142typedef boost::mpl::next<tmp6>::type
tmp7;
143typedef boost::mpl::deref<tmp7>::type
tmp7d;
146typedef boost::mpl::next<tmp7>::type
tmp8;
147typedef boost::mpl::end< inorder_view<tree_seq_hard> >::type
tmp_end;
154 boost::mpl::vector<int, void*, long, double, char>,
155 boost::is_same<_1, _2>
161 boost::mpl::vector<long, short, void*, float, double, int, char>,
162 boost::is_same<_1, _2>
190 boost::mpl::deref< boost::mpl::begin<v1>::type >::type
const i1 = 5;
191 boost::mpl::at< v1, boost::mpl::int_<1> >::type
const c1 =
'a';
193 boost::mpl::prior< boost::mpl::end<v1>::type >::type
194 >::type
const f1 = 2.5;
196 printf(
"i1: (%lu,%i); c1: (%lu,%c); f1: (%lu,%f)\n",
201 typedef boost::mpl::clear<v1>::type v2;
206 typedef boost::mpl::push_front<v2, double>::type v3;
207 typedef boost::mpl::push_back<v3, int>::type v4;
226 typedef boost::mpl::insert<v1, boost::mpl::begin<v1>::type,
float>::type v2;
229 typedef boost::mpl::insert<v2, boost::mpl::end<v2>::type,
char>::type v3;
242 using namespace boost;
247 typedef begin<v1>::type pos0;
248 typedef next<pos0>::type pos1;
249 typedef next<pos1>::type pos2;
250 typedef end<v1>::type posEnd;
262 is_same< erase<v1, pos0, pos2>::type,
tiny<char> >::value));
264 is_same< erase<v1, pos0, posEnd>::type,
tiny<> >::value));
266 is_same< erase<v1, pos1, posEnd>::type,
tiny<int> >::value));
285 printf(
"%lu entries: (%lu, %lu, %lu)\n",
286 mpl::size<seq>::value,
287 mpl::at_c<seq,0>::type::value,
288 mpl::at_c<seq,1>::type::value,
289 mpl::at_c<seq,2>::type::value);
309 typedef mpl::begin<dim1>::type dim_it1;
313 printf(
"%lu entries: (%i, %i, %i)\n",
314 mpl::size<dim1>::value,
315 mpl::at_c<dim1,0>::type::value,
316 mpl::at_c<dim1,1>::type::value,
317 mpl::at_c<dim1,2>::type::value);
324 typedef mpl::push_back< dim1, mpl::int_<3> >::type dim2;
328 typedef mpl::pop_back<dim1>::type dim3;
346template <
typename CurFibIt,
size_t Count>
347struct print_fibonacci
350 typedef print_fibonacci<
351 typename boost::mpl::next<CurFibIt>::type,
358 printf(
"%i ", boost::mpl::deref<CurFibIt>::type::value);
365template <
typename CurFibIt>
371 printf(
"%i ", boost::mpl::deref<CurFibIt>::type::value);
382 typedef print_fibonacci<
383 boost::mpl::begin<fibonacci_series>::type,
387 printf(
"\nFibonacci: { ");
Define a tiny sequence with modifications from examples in Chapter 5.
BOOST_STATIC_ASSERT((boost::is_same< t5, expected_t5 >::value))
Solution to Exercise 5-10.
Solution to Exercise 5-1.
Solution to Exercise 5-6.
Solution to Exercise 5-7.
Solution to Exercise 5-8.
Solution to Exercise 5-9.
static size_t const sMaxFibForInt32
For a 32-bit signed integer, the max Fibonacci sequence seems to be this.
static void test_exercise_5_0()
Tests for Exercise 5-0.
static void test_exercise_5_3()
Tests for Exercise 5-3.
static void test_exercise_5_5()
Tests for Exercise 5-5.
static void test_exercise_5_6()
Tests for Exercise 5-6.
static void test_exercise_5_7()
Tests for Exercise 5-7.
static void print_fibonacci_series()
Give us a nice subroutine to tie Fibonacci seq printout all together.
Exists to inject functionality into the Boost MPL namespace.
Exists to inject functionality into the Boost namespace.
Provide utilities availble to all Chapter 5 solutions.
Encapsulate solution for Exercise 5-10.
Encapsulate solution for Exercise 5-1.
Encapsulate solution for Exercise 5-8.
Tests functionality from Exercise 5-10.
boost::mpl::next< tmp2 >::type tmp3
boost::mpl::next< tmp7 >::type tmp8
boost::mpl::next< tmp3 >::type tmp4
boost::mpl::deref< tmp3 >::type tmp3d
boost::mpl::deref< tmp5 >::type tmp5d
chapter5::tree< double, chapter5::tree< void *, int, long >, char > tree_seq
A test tree.
boost::mpl::next< tmp6 >::type tmp7
boost::mpl::begin< inorder_view< tree_seq_hard > >::type tmp1
boost::mpl::deref< tmp6 >::type tmp6d
boost::mpl::next< tmp4 >::type tmp5
boost::mpl::deref< tmp2 >::type tmp2d
BOOST_STATIC_ASSERT((boost::is_same< long, tmp1d >::value))
boost::mpl::end< inorder_view< tree_seq_hard > >::type tmp_end
boost::mpl::deref< tmp1 >::type tmp1d
boost::mpl::deref< tmp7 >::type tmp7d
chapter5::tree< double, chapter5::tree< short, long, chapter5::tree< float, void * > >, chapter5::tree< int, void_, char > > tree_seq_hard
A more involved test tree.
boost::mpl::next< tmp5 >::type tmp6
boost::mpl::deref< tmp4 >::type tmp4d
boost::mpl::next< tmp1 >::type tmp2
Tests functionality from Exercise 5-1.
BOOST_STATIC_ASSERT((boost::mpl::equal< testVec2, boost::mpl::vector_c< int, 2, 4, 3, 4 > >::value))
boost::mpl::vector_c< int, 1, 2, 3, 4 > testVec
double_first_half< testVec >::type testVec2
Tests functionality from Exercise 5-8.
boost::mpl::advance_c< i, 4 >::type j
BOOST_STATIC_ASSERT(boost::mpl::deref< i >::type::value==8)
boost::mpl::advance_c< boost::mpl::begin< exercise_5_8::fibonacci_series >::type, 6 >::type i
A small, random-access sequence type.
A basic type to represent a binary tree.
Compels iterators to traverse the tree "in order".
Double the values in the first half of the given sequence.
Represent the dimensions in an array type as a sequence of numbers.
Represent the dimensions in an array type as a sequence of numbers.
The Fibonacci series for use with Boost MPL sequences.