C++ Template Metaprogramming
Solutions to the exercises throughout the book
Loading...
Searching...
No Matches

Search a binary tree structure using an inserter. More...

Files

file  exercise-6-4.hpp
 Solution to Exercise 6-4.
 

Namespaces

namespace  anonymous_namespace{chapter-6.cpp}::test_6_4
 Tests functionality from Exercise 6-4.
 
namespace  exercise_6_4
 Encapsulate solution for Exercise 6-4.
 

Classes

struct  boost::mpl::end_impl< chapter5::tree_tag >
 Pass along our special "end" type. More...
 

Detailed Description

Search a binary tree structure using an inserter.

6-4. Write an algorithm metafunction called binary_tree_search that performs
     binary search on trees built using binary_tree_inserter from exercise
     6-3.

typedef binary_tree_search<bst,int_<11> >::type pos1;
typedef binary_tree_search<bst,int_<20> >::type pos2;
typedef mpl::end<bst>::type                     end_pos;

BOOST_STATIC_ASSERT((!boost::is_same< pos1,end_pos >::value));
BOOST_STATIC_ASSERT((boost::is_same< pos2,end_pos >::value));