Boost logo

Boost Users :

Subject: [Boost-users] [Proto] lazy transform is not working
From: Dave Jenkins (david_at_[hidden])
Date: 2009-04-01 16:33:01


In the program below, I expected the proto::lazy transform to call the
times2() function, but it doesn't. It does work correctly if you substitute
times2<int> for proto::_state. Is this a bug or am I forgetting something?

Thanks,
Dave Jenkins

#include <iostream>
#include <boost/proto/proto.hpp>
#include <boost/proto/transform.hpp>
namespace proto = boost::proto;

template<typename T, typename Callable = proto::callable>
struct times2
{
    typedef T result_type;

    T operator()(T i) const
    {
        std::cout << "Called times2()\n";
        return i * 2;
    }
};

struct IntTimes2
    : proto::when<
        proto::terminal<proto::_>
      , proto::lazy<proto::_state(proto::_value) >
    //, proto::lazy<times2<int>(proto::_value) >
>
{};

int main()
{
    int dummy = 0;
    proto::terminal<int>::type i = {1};
    IntTimes2()(i, times2<int>(), dummy);
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net