C++ Template Metaprogramming
Solutions to the exercises throughout the book
Loading...
Searching...
No Matches
exercise-6-3.hpp
Go to the documentation of this file.
1// ===-- chapter-6/exercise-6-3.hpp ----------------------- -*- C++ -*- --=== //
9#ifndef EXERCISE_6_3
10#define EXERCISE_6_3
11
12#include "chapter-6-tree.hpp"
13
14#include <boost/mpl/copy.hpp>
15#include <boost/mpl/placeholders.hpp>
16#include <boost/mpl/vector_c.hpp>
17using namespace boost::mpl::placeholders;
18
19
49namespace exercise_6_3 {
50
58template <typename S, typename Op = boost::mpl::push_back<_, _> >
60{
61 typedef Op operation;
62 typedef S state;
63};
64
66typedef boost::mpl::copy<
67 boost::mpl::vector_c<int, 17, 25, 10, 2, 11>,
69>::type bst;
70
71} // namespace exercise_6_3
72
73#endif // EXERCISE_6_3
Augment the chapter5::tree sequence API to allow addition of elements.
Encapsulate solution for Exercise 6-3.
boost::mpl::copy< boost::mpl::vector_c< int, 17, 25, 10, 2, 11 >, binary_tree_inserter< chapter5::tree<> > >::type bst
A sorted binary tree copied from the source vector.
Basically indistinguishable from from any other inserter since we have a generic insert metafunction.