Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Lazy List

What is provided
Tutorial with examples
Arithmetic functions
List Generation
Implementation Details
Where Next?


Phoenix now has a lazy list implementation which is very similar but not identical to the implementation provided by FC++. This provides a set of objects defined by list<type>, for example this which defines an empty list of type int.

list<int> example;

A list can contain zero or more elements of the same type. It can also be declared using a function returning values of the correct type. Such lists are only evaluated on demand. A set of functions are defined which enable many ways of manipulating and using lists. Examples are provided for the features available.

Exceptions are provided to deal with certain cases and these can be turned off if desired. There is a check on the maximum list length which has a default of 1000 which can be changed by the user.

This is an extension to Boost Phoenix which does not change the public interface except to define new features in the namespace


It has to be explicitly included using the header



Boost Phoenix provides many features of functional_programming. One of the things which has been missing until now is a lazy list implementation. One is available in the library FC++ which although not part of Boost has many similarities. It has been possible to reimplement the strategy of the FC++ List Implementation using the facilties in Phoenix. This provides something which has up until now not been available anywhere in Phoenix and probably not anywhere else in Boost. This new implementation is very well integrated with other features in Phoenix as it uses the same mechanism. In turn that is well integrated with Boost Function.

There is a great deal of material in FC++ and it is not proposed to replicate all of it. A great deal has changed since FC++ was written and many things are already available in Phoenix or elsewhere. The emphasis here is to add to Phoenix in a way which will make it easier to implement functional_programming.

Progress is being made in implementing both the basic list<T> and the functions needed to manipulate lists.