Boost logo

Boost Users :

From: Sohail Somani (s.somani_at_[hidden])
Date: 2006-12-10 21:33:39


Warning: MPL noob, still waiting for my book to arrive

I'm reading the fusion library's documentation that was in the zip file for the announcement. If this is outdated, please ignore this email.

The section in the quickstart:

Print Only Pointers
===================

Let's get a little cleverer. Say we wish to write a generic function that takes in an arbitrary sequence and XML prints only those elements which are pointers. Ah, easy. First, let's include the is_pointer boost type trait:

#include <boost/type_traits/is_pointer.hpp>

Then, simply:

template <typename Sequence>
void xml_print_pointers(Sequence const& seq)
{
    for_each(filter_if<boost::is_pointer<Sequence> >(seq), print_xml());
}
====================

This doesn't seem to compile as is. I needed to do the following instead of the above:

template <typename Sequence>
void xml_print_pointers(Sequence const& seq)
{
    using namespace mpl::placeholders;
    typedef mpl::lambda<boost::is_pointer<_1> >::type is_pointer;
    fusion::for_each(fusion::filter_if<is_pointer>(seq), print_xml());
}

This is using boost 1.33.1.

Did I miss something?

Thanks!

Sohail



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net