C++ Template Metaprogramming
Solutions to the exercises throughout the book
|
Insert into a binary tree. More...
Files | |
file | exercise-6-3.hpp |
Solution to Exercise 6-3. | |
Namespaces | |
namespace | anonymous_namespace{chapter-6.cpp}::test_6_3 |
Tests functionality from Exercise 6-3. | |
namespace | exercise_6_3 |
Encapsulate solution for Exercise 6-3. | |
Insert into a binary tree.
6-3. Write an inserter class template called binary_tree_inserter that employs the tree template from exercise 5-10 to incrementally build a binary search tree: typedef mpl::copy< mpl::vector_c<int,17,25,10,2,11> , binary_tree_inserter< tree<> > >::type bst; // int_<17> // / \ // int_<10> int_<25> // / \ // int_<2> int_<11> BOOST_STATIC_ASSERT(( mpl::equal< inorder_view<bst> , mpl::vector_c<int,2,10,11,17,25> >::value ));