Boost logo

Boost :

Subject: [boost] Lazy list
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-01-17 21:35:17


It occured to me that boost is lacking a true lazy list. I feel like this
should be possible to implement on most compilers, although I doubt I have
the metaprogramming expertise to be able to implement such a data structure
myself. But nonetheless I think this would be extremely useful. Lazy lists
are basically lists that don't store the actual values of the list, instead
they store a -function- that is called each time the next element of the
list is requested, and the result of that list is returned. Most likely
there is a caching mechanism as well, so that accessing recently accessed
(or preceding) elements would return a cached value if it had already been
accessed. I guess it would not cache arbitrarily large amounts of elements
though for memory usage reasons, otherwise it would defeat the whole
purpose, which is the ability to expose truly infinite sequences to the user
in the form of a list.

Has this been considered before, and can anyone think of any technical
limitations that would prevent such a class to be written?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk