Use mpl::copy with a hand-built inserter to write a smallest metafunction that finds the smallest of a sequence of types. That is:

            smallest< mpl::vector<int[2], char, double&> >::type
          , char

Now that you've done it, is it a good way to solve that problem? Why or why not?


Rewrite the binary template from section 1.4.1 using one of the MPL sequence iteration algorithms, and write a test program that will only compile if your binary template is working. Compare the amount of code you wrote with the version using handwritten recursion presented in Chapter 1. What characteristics of the problem caused that result?


Because std::for_each is the most basic algorithm in the standard library, you may be wondering why we didn't say anything about its compile time counterpart. The fact is that unlike, for example, transform, the algorithm does not have a pure compile time counterpart. Can you offer an explanation for that fact?


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<
        , binary_tree_inserter< tree<> >
        >::type bst;

    //       int_<17>
    //       /      \
    //    int_<10>  int_<25>
    //     /    \
    // int_<2> int_<11>
    BOOST_STATIC_ASSERT(( mpl::equal<
        , mpl::vector_c<int,2,10,11,17,25>
        >::value ));


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));


List all algorithms in the standard library and compare their set to the set of algorithms provided by MPL. Analyze the differences. What algorithms are named differently? What algorithms have different semantics? What algorithms are missing? Why do you think they are missing?

     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows