Regular users of the C++ library known as Boost will already know about functors, lambda functions, and the like. These abilities mostly originate in the Boost.Bind and Boost.Lambda libraries.
As I'll soon be using the functor capability within my C++ programs, I wanted to
make a 'note-to-self' regarding the fact that Boost.Bind and Boost.Lambda have basically
been superceded by Boost.Spirit.Phoenix.
The Phoenix library has been accepted into Boost based upon
Hartmut's summary of the Phoenix review.
The current incarnation of the
Boost libraries is 1.39. Here is the
Spirit User's Guide which includes a link to the
Phoenix Documentation and a link to the
Phoenix Users Guide.
It is noted that FC++ influenced Phoenix, and when looking at the
FC++ web site, there
is a reference to
LC++, which is a Logic Programming
language built atop of FC++. I wonder if something similar has been done atop of Phoenix.
An example from the Boost Mailing List of using Phoenix:
#include <vector>
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include <boost/spirit/home/phoenix/core.hpp>
#include <boost/spirit/home/phoenix/operator.hpp>
#include <boost/spirit/home/phoenix/bind/bind_function.hpp>
struct A {};
void foo( const A& ) {}
int main()
{
using namespace boost::phoenix;
using namespace boost::phoenix::arg_names;
std::vector< boost::shared_ptr< A > > vec;
vec.push_back( boost::shared_ptr< A >( new A ) );
std::for_each( vec.begin(), vec.end(),
bind( &foo, *arg1 ) );
return 0;
}
Colorized with CodeColorizer.