
Joel de Guzman wrote:
Hi,
Hi. Here's a preview of Phoenix V2. This will probably be the last release of the library. Phoenix V2 will be the basis of the Phoenix and Boost.Lambda merger.
You can get it here: http://spirit.sourceforge.net/dl_more/phoenix-2.zip
I like it!
You can browse the draft docs here: http://tinyurl.com/6crgp
There is a typeo in the table at composite.html#phoenix.operator: Include Files: #include <boost/spirit/phoenix/operator/self.hppp> ---------------------------------------------------^
What's new? A lot. This is a total rewrite based on earlier discussions with Jaakko Jarvi. The library's is built on top of Fusion and of course MPL.
Of particular interest are local variables and lambda-lambda scopes: http://tinyurl.com/3mn6w
There is also a set of lazy functions that work on STL sequences (e.g. push_back etc.): http://tinyurl.com/46bbm
and pretty soon, a final TODO item (built on top of scopes/ lambda), lazy STL algorithms (e.g. find_if, etc). The scopes section (link provided above) in the docs illustrates how to write lazy functions that accept higher order functions (e.g. for_each).
I have written lazy veraions of pair.first and pair.second (see attachment). Regards, Reece // (C) Copyright 2004: Reece H. Dunn. Distributed under the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_SPIRIT_PHOENIX_STL_UTILITY_HPP #define BOOST_SPIRIT_PHOENIX_STL_UTILITY_HPP #include <boost/spirit/phoenix/function/function.hpp> namespace boost { namespace phoenix { namespace stl { template< typename C > struct first_type_of{ typedef typename C::first_type type; }; template< typename C > struct second_type_of{ typedef typename C::second_type type; }; struct first { template< typename C > struct apply { typedef typename first_type_of< C >::type & type; }; template< typename C > typename apply< C >::type operator()( C & c ) const { return c.first; } }; struct second { template< typename C > struct apply { typedef typename second_type_of< C >::type & type; }; template< typename C > typename apply< C >::type operator()( C & c ) const { return c.second; } }; } /** Get the first item in a pair. * The standard way of accessing the first item in a pair is to use the * p.first syntax. This will not work in a lazy context: * arg1.first; // error: first not a member of arg1. * To make this work in a lazy context, you need to use the first function: * first( arg1 ); // lazy evaluation. */ function< stl::first > const first = stl::first(); /** Get the second item in a pair. * The standard way of accessing the second item in a pair is to use the * p.second syntax. This will not work in a lazy context: * arg1.second; // error: second not a member of arg1. * To make this work in a lazy context, you need to use the second function: * second( arg1 ); // lazy evaluation. */ function< stl::second > const second = stl::second(); }} #endif