Boost logo

Boost Users :

Subject: [Boost-users] MPL: Lazy Evaluation and Nullary Metafunction
From: Missing Rainbow (d0253082_at_[hidden])
Date: 2008-10-16 15:56:37

Hi All,

I am reading about the lazy evaluation and nullary metafunction in the
MPL book. While discussing the lazy evaluation technique the
following code is presented (page 57):

struct add_pointer_f
    template <class T>
    struct apply : boost::add_pointer<T> {};
typedef mpl::vector<int, char*, double&> seq;
typedef mpl::transform<seq, boost::add_pointer<_> > calc_ptr_seq;

The point of the above code was to demonstrate that the nullary
metafunction calc_ptr_seq represents the sequence "int*, char**,
double&*", even though the last element in that sequence is not valid.
 Thanks to lazy evaluation. As long as we don't access the third
element in the sequence represented by calc_ptr_seq, everything should
work fine. Is my understanding correct?

Also, other than nullary metafunction, is there any other approach to
lazy evaluation? Or will lazy evaluation _always_ be implemented with
the help of nullary metafunction?

Thank you.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at